Commit 86c29e75 authored by Sven Franck's avatar Sven Franck

clean up folder structure

parent f144c000
......@@ -8,11 +8,13 @@
, paths: {
// core
app: '../js/app'
, polyfill: '../js/polyfill'
, overrides: '../js/overrides'
, utilities: '../js/utilities'
, extensions: '../modules/extensions/extensions'
app: '../modules/core/app/app'
, config: '../modules/core/config/config'
, polyfill: '../modules/core/polyfill/polyfill'
, overrides: '../modules/core/overrides/overrides'
, utilities: '../modules/core/utilities/utilities'
, extensions: '../modules/core/extensions/extensions'
, storage: '../modules/core/storage/storage'
// requireJs
, almond: '../js/libs/require/almond'
......@@ -22,13 +24,15 @@
, json: '../js/plugins/requirejs-plugins/json'
, async: '../js/plugins/requirejs-plugins/async'
// support
, modernizr: '../js/plugins/modernizr'
, selectivzr: '../js/plugins/selectivzr'
// plugins/libs
, jquery: '../js/libs/jquery/jquery'
, jqm: '../js/libs/jquery-mobile/jquery-mobile'
, i18next: '../js/plugins/i18next/i18next'
, renderjs: '../js/plugins/renderjs/renderjs'
, modernizr: '../js/plugins/modernizr'
, selectivzr: '../js/plugins/selectivzr'
, jio: '../js/libs/jio/jio'
, md5: '../js/libs/jio/md5'
, localstorage: '../js/libs/jio/localstorage'
......@@ -37,36 +41,34 @@
, validval: '../js/plugins/validval/validval'
// page gadgets
, address: '../modules/address/address'
, basket: '../modules/basket/basket'
, browser: '../modules/browser/browser'
, config: '../modules/config/config'
, confirm: '../modules/confirm/confirm'
, description: '../modules/description/description'
, details: '../modules/details/details'
, footer: '../modules/footer/footer'
, gallery: '../modules/gallery/gallery'
, header: '../modules/header/header'
, index: '../modules/index/index'
, item: '../modules/item/item'
, items: '../modules/items/items'
, login: '../modules/login/login'
, media: '../modules/media/media'
, payment: '../modules/payment/payment'
, refine: '../modules/refine/refine'
, register: '../modules/register/register'
, products: '../modules/products/products'
, searchbar: '../modules/searchbar/searchbar'
, seo: '../modules/seo/seo'
, shipment: '../modules/shipment/shipment'
, sorting: '../modules/sorting/sorting'
, storage: '../modules/storage/storage'
, summary: '../modules/summary/summary'
, teaser: '../modules/teaser/teaser'
, terms: '../modules/terms/terms'
, translate: '../modules/translate/translate'
, pageheader: '../modules/pageheader/pageheader'
, pagefooter: '../modules/pagefooter/pagefooter'
, address: '../modules/ui/address/address'
, basket: '../modules/ui/basket/basket'
, browser: '../modules/ui/browser/browser'
, confirm: '../modules/ui/confirm/confirm'
, description: '../modules/ui/description/description'
, details: '../modules/ui/details/details'
, footer: '../modules/ui/footer/footer'
, gallery: '../modules/ui/gallery/gallery'
, header: '../modules/ui/header/header'
, index: '../modules/ui/index/index'
, item: '../modules/ui/item/item'
, items: '../modules/ui/items/items'
, login: '../modules/ui/login/login'
, media: '../modules/ui/media/media'
, payment: '../modules/ui/payment/payment'
, refine: '../modules/ui/refine/refine'
, register: '../modules/ui/register/register'
, products: '../modules/ui/products/products'
, searchbar: '../modules/ui/searchbar/searchbar'
, seo: '../modules/ui/seo/seo'
, shipment: '../modules/ui/shipment/shipment'
, sorting: '../modules/ui/sorting/sorting'
, summary: '../modules/ui/summary/summary'
, teaser: '../modules/ui/teaser/teaser'
, terms: '../modules/ui/terms/terms'
, translate: '../modules/ui/translate/translate'
, pageheader: '../modules/ui/pageheader/pageheader'
, pagefooter: '../modules/ui/pagefooter/pagefooter'
}
, shim: {
'jqm': { deps: ['jquery'], exports: 'mobile' }
......
File mode changed from 100755 to 100644
/* =========================== action button ========================*/
.ui-input-search-no-pseudo:after {
content: none;
}
.ui-input-search .ui-input-action {
position: absolute;
right: 0;
top: 50%;
margin: -15px .3125em 0;
border: 0;
background-color: transparent;
}
/* =========================== carousel widget ========================*/
.ui-carousel {
list-style: none outside none;
margin: 0 auto;
padding: 0;
position: relative;
text-align: center;
width: auto;
min-height: 25em;
overflow: hidden; /* firefox seems the only browser to properly overflow-hide round corners... */
margin: 0 -15px;
}
.ui-carousel-inset {
margin: 1em auto;
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
border-radius: 1em;
}
.ui-carousel li {
list-style: none;
width: 100%;
position: absolute;
display: none;
height: 100%;
-webkit-border-radius: inherit;
-moz-border-radius: inherit;
border-radius: inherit;
overflow: inherit;
min-height: inherit;
}
.ui-carousel li.ui-carousel-transitioning {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.ui-carousel li.ui-carousel-active {
display: block;
}
.ui-carousel li a {
height: inherit;
-webkit-border-radius: inherit;
-moz-border-radius: inherit;
border-radius: inherit;
overflow: inherit;
min-height: inherit;
}
.ui-carousel img {
width: 100%;
display: block;
-webkit-border-radius: inherit;
-moz-border-radius: inherit;
border-radius: inherit;
min-height: inherit;
}
.ui-carousel-controls {
text-align: center;
}
.ui-carousel-controls .ui-radio {
display: inline-block;
padding: 0 0.25em;
}
.ui-carousel-controls .ui-radio input:checked {
border: 1px solid red !important;
}
.ui-carousel-captions .ui-carousel-captions-heading {
margin: 0;
padding: 0;
}
.ui-carousel-captions-content {
left: 0;
margin: 0;
padding: 0.5em 0;
position: absolute;
right: 0;
}
.ui-carousel-captions-bottom {
bottom: 0;
}
.ui-carousel-captions-top {
top: 0;
}
@media (max-width: 77.5em) {
.ui-carousel.ui-responsive {
max-width: 80%;
}
}
@media (max-width: 45em) {
.ui-carousel.ui-responsive {
max-width: 85%;
}
}
@media (max-width: 40em) {
.ui-carousel.ui-responsive {
max-width: 90%;
}
}
@media (max-width: 30em) {
.ui-carousel.ui-responsive {
max-width: 90%;
}
}
@media (max-width: 20em) {
.ui-carousel.ui-responsive {
max-width: 90%;
}
}
\ No newline at end of file
define([
'jquery'
, 'jqm'
, 'css!extensions'
], function ($) {
"use strict";
// this module adds extensions to JQM
/* ========================= GALLERY WIDGET ========================= */
(function( $, undefined ) {
$.widget( "mobile.carousel", {
options: {
bullets: null,
bulletsPos: null,
inset: null,
captions: null,
captionpos: null,
captiontheme: null,
carouseltransition: null,
heading: "h1,h2,h3,h4,h5,h6,legend"
},
_transitionEndEvents : "webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",
_create: function () {
var el = this.element[0],
o = this.options,
getAttrFixed = $.mobile.getAttribute;
// only time we read the DOM config
o.inset = getAttrFixed(el, "inset", true) || false;
o.carouseltransition = getAttrFixed(el, "transition", true) || "slide";
o.bullets = getAttrFixed(el, "bullets", true) || true;
o.captions = getAttrFixed(el, "captions", true) || false;
if (o.captions) {
o.captionspos = getAttrFixed(el, "captions-pos", true) || "bottom";
o.captionstheme = getAttrFixed(el, "captions-theme", true) || "a";
}
if (o.bullets) {
o.bulletsPos = getAttrFixed(el, "bulletsPos", true) || "bottom";
}
this.refresh(true);
},
refresh: function (create) {
var o = this.options,
el = this.element,
items = el.children(),
fragment = document.createDocumentFragment(),
classes = "ui-carousel",
label,
radio,
barrel,
item,
i,
transition,
containsLinks,
captionsContent,
captionsHeading;
// loop over images
for (i = 0; i < items.length; i += 1) {
var item = items[i];
// create captions
if (o.captions) {
containsLinks = item.children.length === 1 && item.children[0].tagName === "A";
captionsContent = $( item )
.find(containsLinks ? "a *" : "*")
.not("img")
.wrap( "<div class='ui-carousel-captions-content ui-bar-" + o.captionstheme + " ui-carousel-captions-" + o.captionspos + "'></div>")
.parent();
captionsHeading = captionsContent.find(o.heading).addClass("ui-carousel-captions-heading");
}
// create radios
if (o.bullets) {
// TODO: do this in jQuery...
radio = document.createElement("input");
radio.setAttribute("type", 'radio');
radio.setAttribute("name", 'radio-' + this.uuid );
radio.setAttribute("value",'radio-' + this.uuid + '-' + i);
if (i === 0) {
radio.checked = true;
$(item).addClass("ui-carousel-active");
}
// and use data()
radio.reference = $(item);
label = document.createElement("label");
label.setAttribute("data-" + $.mobile.ns + "iconpos", "notext");
label.appendChild( radio );
fragment.appendChild( label )
}
}
if (o.inset) {
classes += " ui-carousel-inset";
}
if (o.captions) {
classes += " ui-carousel-captions";
}
if (o.bullets) {
classes += " ui-carousel-bullets";
barrel = $("<div class='ui-carousel-controls ui-carousel-controls-" + o.bulletPos +"' />");
while ( fragment.firstChild ) {
// browser hangs up if calling this inside append()
$(fragment.firstChild).children().checkboxradio();
barrel.append(
fragment.firstChild
);
}
// this always needs to go before the slider
el[o.bulletPos === "top" ? "before" : "after"](barrel);
this._on(barrel.find("input"), { change: "_onChange"});
}
// all set, add classes
el.addClass(classes);
},
// _handleKeydown: function( event ) {
// var index = this._value();
// if ( this.options.disabled ) {
// return;
// }
//
// // In all cases prevent the default and mark the handle as active
// switch ( event.keyCode ) {
// case $.mobile.keyCode.RIGHT:
// case $.mobile.keyCode.LEFT:
// event.preventDefault();
//
// if ( !this._keySliding ) {
// this._keySliding = true;
// this.handle.addClass( "ui-state-active" ); /* TODO: We don't use this class for styling. Do we need to add it? */
// }
//
// break;
// }
//
// // move the slider according to the keypress
// switch ( event.keyCode ) {
// case $.mobile.keyCode.RIGHT:
// this.refresh( index + this.step );
// break;
// case $.mobile.keyCode.LEFT:
// this.refresh( index - this.step );
// break;
// }
// }, // remove active mark
//
// _handleKeyup: function(/* event */) {
// if ( this._keySliding ) {
// this._keySliding = false;
// this.handle.removeClass( "ui-state-active" ); /* See comment above. */
// }
// },
// _bindSwipeEvents: function() {
// var self = this,
// area = self.element;
//
// // on swipe, change to the next/previous image
// if( !!self.options.swipeClose ) {
// if ( self.options.position === "left" ) {
// area.on( "swipeleft.carousel", function(/* e */) {
// // self.close();
// });
// } else {
// area.on( "swiperight.carousel", function(/* e */) {
// // self.close();
// });
// }
// }
// },
_completeTransition: function (current, next, events) {
var self = this,
o = self.options;
next.removeClass("in out " + o.carouseltransition)
.off( events );
current
.on( events, self._cleanupTransition(current, events) )
},
_cleanupTransition: function (current, events) {
var self = this,
o = self.options;
var classes = o.carouseltransition + " out in";
current.removeClass(classes)
current.removeClass("ui-carousel-active").off(events);
},
_onChange: function (e) {
var self = this,
events = self._transitionEndEvents,
el = self.element,
o = self.options,
// elements
currentActive = el.children().filter(".ui-carousel-active"),
nextActive = e.target.reference,
classes = o.carouseltransition + " out in",
transition = $.mobile._maybeDegradeTransition( o.carouseltransition );
// click on active radio
if (nextActive.hasClass("ui-carousel-active")) {
return;
}
// initialize
nextActive
.on( events, self._completeTransition(currentActive, nextActive, events));
nextActive
.addClass(transition + " ui-carousel-active in ");
}
});
$.mobile.carousel.initSelector = ":jqmData(role='carousel')";
//auto self-init widgets
$.mobile._enhancer.add( "mobile.carousel" );
})( jQuery );
/* tranistion workflow
// first slide
if (init) {
current.removeClass("ui-carousel-active in out reverse slide")
next.css('z-index','-10')
.addClass("ui-carousel-active ui-carousel-opaque")
.css('z-index','')
if (transition !== "none") {
// > once animation is complete!
// current.removeClass("ui-carousel-active in out reverse slide")
// next.removeClass("out in reverse slide")
next.removeClass("ui-carousel-opaque")
.addClass("slide in reverse")
} else {
current.removeClass("ui-carousel-active in out reverse slide")
next.removeClass("out in reverse slide")
}
} else {
// > once animation is complete
current.removeClass("ui-carousel-active in out reverse slide")
next.css('z-index','-10')
.addClass("ui-carousel-active ui-carousel-opaque")
.css('z-index','')
if (transition !== "none") {
// > once animation is complete!
// current.removeClass("ui-carousel-active in out reverse slide")
// next.removeClass("out in reverse slide")
next.removeClass("ui-carousel-opaque")
.addClass("slide in reverse")
} else {
current.removeClass("ui-carousel-active in out reverse slide")
next.removeClass("out in reverse slide")
}
current.addClass("slide out reverse");
}
*/
/* ========================= ACTION BUTTON EXTENSION ==================== */
(function( $, undefined ) {
$.widget( "mobile.textinput", $.mobile.textinput, {
options: {
actionBtn: false,
actionBtnText: "Search",
actionBtnIcon: "search",
},
_create: function(){
this._super();
if( !!this.options.actionBtn || this.isSearch ){
this._addActionBtn();
}
},
actionButton: function(){
return $( "<a href='#' class='ui-input-action ui-btn ui-icon-" + this.options.actionBtnIcon + " ui-btn-icon-notext ui-corner-all" +
"' title='" + this.options.actionBtnText + "'>" + this.options.actionBtnText + "</a>" );
},
_addActionBtn: function(){
if( !this.options.enhanced ) {
this._enhanceAction();
}
$.extend( this, {
_actionBtn: this.widget().find("a.ui-input-action")
});
},
_enhanceAction: function() {
this.actionButton().appendTo( this.widget() );
this.widget().addClass( "ui-input-has-action ui-input-search-no-pseudo" );
},
_setOptions:function( options ) {
this._super( options );
if( options.actionBtn !== undefined && !this.element.is( "textarea, :jqmData(type='range')" ) ) {
if( options.actionBtn ){
this._addActionBtn();
} else {
this._destroyAction();
}
}
if( options.clearBtnText !== undefined && this._actionBtn !== undefined ) {
this._actionBtn.text( options.clearBtnText );
}
},
_destroyAction: function() {
this.element.removeClass( "ui-input-has-clear" );
this._actionBtn.remove();
},
_destroy: function() {
this._super();
this._destroyAction();
}
});
})( jQuery );
return undefined;
});
\ No newline at end of file
/* ============================ CAROUSEL WIDGET ========================== */
(function( $, undefined ) {
"use strict";
$.widget("mobile.carousel", $.mobile.widget, {
options: {
bullets: null,
bulletsPos: null,
inset: null,
captions: null,
captionpos: null,
captiontheme: null,
carouseltransition: null,
heading: "h1,h2,h3,h4,h5,h6,legend"
},
_transitionEndEvents : "webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",
_create: function () {
var el = this.element[0],
o = this.options,
getAttrFixed = $.mobile.getAttribute;
// only time we read the DOM config
o.inset = getAttrFixed(el, "inset", true) || false;
o.carouseltransition = getAttrFixed(el, "transition", true) || "slide";
o.bullets = getAttrFixed(el, "bullets", true) || true;
o.captions = getAttrFixed(el, "captions", true) || false;
if (o.captions) {
o.captionspos = getAttrFixed(el, "captions-pos", true) || "bottom";
o.captionstheme = getAttrFixed(el, "captions-theme", true) || "a";
}
if (o.bullets) {
o.bulletsPos = getAttrFixed(el, "bulletsPos", true) || "bottom";
}
this.refresh(true);
},
refresh: function (create) {
var o = this.options,
el = this.element,
items = el.children(),
fragment = document.createDocumentFragment(),
classes = "ui-carousel",
label,
radio,
barrel,
item,
i,
transition,
containsLinks,
captionsContent,
captionsHeading;
// loop over images
for (i = 0; i < items.length; i += 1) {
var item = items[i];
// create captions
if (o.captions) {
containsLinks = item.children.length === 1 && item.children[0].tagName === "A";
captionsContent = $( item )
.find(containsLinks ? "a *" : "*")
.not("img")
.wrap( "<div class='ui-carousel-captions-content ui-bar-" + o.captionstheme + " ui-carousel-captions-" + o.captionspos + "'></div>")
.parent();
captionsHeading = captionsContent.find(o.heading).addClass("ui-carousel-captions-heading");
}
// create radios
if (o.bullets) {
// TODO: do this in jQuery...
radio = document.createElement("input");
radio.setAttribute("type", 'radio');
radio.setAttribute("name", 'radio-' + this.uuid );
radio.setAttribute("value",'radio-' + this.uuid + '-' + i);
if (i === 0) {
radio.checked = true;
$(item).addClass("ui-carousel-active");
}
// and use data()
radio.reference = $(item);
label = document.createElement("label");
label.setAttribute("data-" + $.mobile.ns + "iconpos", "notext");
label.appendChild( radio );
fragment.appendChild( label )
}
}
if (o.inset) {
classes += " ui-carousel-inset";
}
if (o.captions) {
classes += " ui-carousel-captions";
}
if (o.bullets) {
classes += " ui-carousel-bullets";
barrel = $("<div class='ui-carousel-controls ui-carousel-controls-" + o.bulletPos +"' />");
while ( fragment.firstChild ) {
// browser hangs up if calling this inside append()
$(fragment.firstChild).children().checkboxradio();
barrel.append(
fragment.firstChild
);
}
// this always needs to go before the slider
el[o.bulletPos === "top" ? "before" : "after"](barrel);
this._on(barrel.find("input"), { change: "_onChange"});
}
// all set, add classes
el.addClass(classes);
},
// _handleKeydown: function( event ) {
// var index = this._value();
// if ( this.options.disabled ) {
// return;
// }
//
// // In all cases prevent the default and mark the handle as active
// switch ( event.keyCode ) {
// case $.mobile.keyCode.RIGHT:
// case $.mobile.keyCode.LEFT:
// event.preventDefault();
//
// if ( !this._keySliding ) {
// this._keySliding = true;
// this.handle.addClass( "ui-state-active" ); /* TODO: We don't use this class for styling. Do we need to add it? */
// }
//
// break;
// }
//
// // move the slider according to the keypress
// switch ( event.keyCode ) {
// case $.mobile.keyCode.RIGHT:
// this.refresh( index + this.step );
// break;
// case $.mobile.keyCode.LEFT:
// this.refresh( index - this.step );
// break;
// }
// }, // remove active mark
//
// _handleKeyup: function(/* event */) {
// if ( this._keySliding ) {
// this._keySliding = false;
// this.handle.removeClass( "ui-state-active" ); /* See comment above. */
// }
// },
// _bindSwipeEvents: function() {
// var self = this,
// area = self.element;
//
// // on swipe, change to the next/previous image
// if( !!self.options.swipeClose ) {
// if ( self.options.position === "left" ) {
// area.on( "swipeleft.carousel", function(/* e */) {
// // self.close();
// });
// } else {
// area.on( "swiperight.carousel", function(/* e */) {
// // self.close();
// });
// }
// }
// },
_completeTransition: function (current, next, events) {
var self = this,
o = self.options;
console.log("3. NEXT: removing 'in out slide'")
next.removeClass("in out " + o.carouseltransition)
.off( events );
console.log("4. CURRENT: setting bindings");
current
.on( events, self._cleanupTransition(current, events) )
},
_cleanupTransition: function (current, events) {
var self = this,
o = self.options;
var classes = o.carouseltransition + " out in";
console.log("5. CURRENT: removing 'in out slide'");
current.removeClass(classes)
console.log("6. CURRENT: removing 'active'");
current.removeClass("ui-carousel-active").off(events);
},
_onChange: function (e) {
var self = this,
events = self._transitionEndEvents,
el = self.element,
o = self.options,
// elements
currentActive = el.children().filter(".ui-carousel-active"),
nextActive = e.target.reference,
classes = o.carouseltransition + " out in",
transition = $.mobile._maybeDegradeTransition( o.carouseltransition );
// click on active radio
if (nextActive.hasClass("ui-carousel-active")) {
return;
}
// initialize
nextActive
.on( events, self._completeTransition(currentActive, nextActive, events));
console.log("2. NEXT: adding 'slide in active'");
nextActive
.addClass(transition + " ui-carousel-active in ");
}
});
$.mobile.carousel.initSelector = ":jqmData(role='carousel')";
//auto self-init widgets
$.mobile._enhancer.add( "mobile.carousel" );
})( jQuery );
/* tranistion workflow
// first slide
if (init) {
current.removeClass("ui-carousel-active in out reverse slide")
next.css('z-index','-10')
.addClass("ui-carousel-active ui-carousel-opaque")
.css('z-index','')
if (transition !== "none") {
// > once animation is complete!
// current.removeClass("ui-carousel-active in out reverse slide")
// next.removeClass("out in reverse slide")
next.removeClass("ui-carousel-opaque")
.addClass("slide in reverse")
} else {
current.removeClass("ui-carousel-active in out reverse slide")
next.removeClass("out in reverse slide")
}
} else {
// > once animation is complete
current.removeClass("ui-carousel-active in out reverse slide")
next.css('z-index','-10')
.addClass("ui-carousel-active ui-carousel-opaque")
.css('z-index','')
if (transition !== "none") {
// > once animation is complete!
// current.removeClass("ui-carousel-active in out reverse slide")
// next.removeClass("out in reverse slide")
next.removeClass("ui-carousel-opaque")
.addClass("slide in reverse")
} else {
current.removeClass("ui-carousel-active in out reverse slide")
next.removeClass("out in reverse slide")
}
current.addClass("slide out reverse");
}
*/
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
// AMD wrapper
(function ( root, doc, factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery" ], function ( $ ) {
factory( $, root, doc );
return $.rjs;
});
} else {
// Browser globals
factory( root.jQuery, root, doc );
}
}( this, document, function ( jQuery, window, document, undefined ) {
// container
(function( $ ) {
$.rjs = {};
}( jQuery ));
(function( $, window, undefined ) {
$.extend($.mobile, {
// Version of the jQuery Mobile Framework
version: "1.4.0pre",
// Define the url parameter used for referencing widget-generated sub-pages.
// Translates to to example.html&ui-page=subpageIdentifier
// hash segment before &ui-page= is used to make Ajax request
subPageUrlKey: "ui-page",
// Class assigned to page currently in view, and during transitions
activePageClass: "ui-page-active",
// Class used for "active" button state, from CSS framework
activeBtnClass: "ui-btn-active",
// Class used for "focus" form element state, from CSS framework
focusClass: "ui-focus",
// Automatically handle clicks and form submissions through Ajax, when same-domain
ajaxEnabled: true,
// Automatically load and show pages based on location.hash
hashListeningEnabled: true,
// disable to prevent jquery from bothering with links
linkBindingEnabled: true,
// Set default page transition - 'none' for no transitions
defaultPageTransition: "fade",
// Set maximum window width for transitions to apply - 'false' for no limit
maxTransitionWidth: false,
// Minimum scroll distance that will be remembered when returning to a page
minScrollBack: 250,
// DEPRECATED: the following property is no longer in use, but defined until 2.0 to prevent conflicts
touchOverflowEnabled: false,
// Set default dialog transition - 'none' for no transitions
defaultDialogTransition: "pop",
// Error response message - appears when an Ajax page request fails
pageLoadErrorMessage: "Error Loading Page",
// For error messages, which theme does the box uses?
pageLoadErrorMessageTheme: "e",
// replace calls to window.history.back with phonegaps navigation helper
// where it is provided on the window object
phonegapNavigationEnabled: false,
//automatically initialize the DOM when it's ready
autoInitializePage: true,
pushStateEnabled: true,
// allows users to opt in to ignoring content by marking a parent element as
// data-ignored
ignoreContentEnabled: false,
buttonMarkup: {
hoverDelay: 200
},
// disable the alteration of the dynamic base tag or links in the case
// that a dynamic base tag isn't supported
dynamicBaseEnabled: true,
// default the property to remove dependency on assignment in init module
pageContainer: $()
});
})( jQuery, this );
(function( $, window, undefined ) {
var nsNormalizeDict = {},
// Monkey-patching Sizzle to filter the :jqmData selector
oldFind = $.find,
rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
jqmDataRE = /:jqmData\(([^)]*)\)/g;
$.extend($.mobile, {
// Namespace used framework-wide for data-attrs. Default is no namespace
ns: "",
// Retrieve an attribute from an element and perform some massaging of the value
getAttribute: function( e, key, dns ) {
var data;
if ( dns ) {
key = "data-" + $.mobile.ns + key;
}
data = e.getAttribute( key );
// Copied from core's src/data.js:dataAttr()
// Convert from a string to a proper data type
try {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
// Only convert to a number if it doesn't change the string
+data + "" === data ? +data :
rbrace.test( data ) ? JSON.parse( data ) :
data;
} catch( err ) {}
return data;
},
// Expose our cache for testing purposes.
nsNormalizeDict: nsNormalizeDict,
// Take a data attribute property, prepend the namespace
// and then camel case the attribute string. Add the result
// to our nsNormalizeDict so we don't have to do this again.
nsNormalize: function( prop ) {
return nsNormalizeDict[ prop ] || ( nsNormalizeDict[ prop ] = $.camelCase( $.mobile.ns + prop ) );
},
// Find the closest javascript page element to gather settings data jsperf test
// http://jsperf.com/single-complex-selector-vs-many-complex-selectors/edit
// possibly naive, but it shows that the parsing overhead for *just* the page selector vs
// the page and dialog selector is negligable. This could probably be speed up by
// doing a similar parent node traversal to the one found in the inherited theme code above
closestPageData: function( $target ) {
return $target
.closest( ":jqmData(role='page'), :jqmData(role='dialog')" )
.data( "mobile-page" );
}
});
// Mobile version of data and removeData and hasData methods
// ensures all data is set and retrieved using jQuery Mobile's data namespace
$.fn.jqmData = function( prop, value ) {
var result;
if ( typeof prop !== "undefined" ) {
if ( prop ) {
prop = $.mobile.nsNormalize( prop );
}
// undefined is permitted as an explicit input for the second param
// in this case it returns the value and does not set it to undefined
if( arguments.length < 2 || value === undefined ){
result = this.data( prop );
} else {
result = this.data( prop, value );
}
}
return result;
};
$.jqmData = function( elem, prop, value ) {
var result;
if ( typeof prop !== "undefined" ) {
result = $.data( elem, prop ? $.mobile.nsNormalize( prop ) : prop, value );
}
return result;
};
$.fn.jqmRemoveData = function( prop ) {
return this.removeData( $.mobile.nsNormalize( prop ) );
};
$.jqmRemoveData = function( elem, prop ) {
return $.removeData( elem, $.mobile.nsNormalize( prop ) );
};
$.find = function( selector, context, ret, extra ) {
selector = selector.replace( jqmDataRE, "[data-" + ( $.mobile.ns || "" ) + "$1]" );
return oldFind.call( this, selector, context, ret, extra );
};
$.extend( $.find, oldFind );
})( jQuery, this );
/*!
* jQuery UI Core @VERSION
* http://jqueryui.com
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/category/ui-core/
*/
(function( $, undefined ) {
var uuid = 0,
runiqueId = /^ui-id-\d+$/;
// $.ui might exist from components with no dependencies, e.g., $.ui.position
$.ui = $.ui || {};
$.extend( $.ui, {
version: "@VERSION",
keyCode: {
BACKSPACE: 8,
COMMA: 188,
DELETE: 46,
DOWN: 40,
END: 35,
ENTER: 13,
ESCAPE: 27,
HOME: 36,
LEFT: 37,
PAGE_DOWN: 34,
PAGE_UP: 33,
PERIOD: 190,
RIGHT: 39,
SPACE: 32,
TAB: 9,
UP: 38
}
});
// plugins
$.fn.extend({
focus: (function( orig ) {
return function( delay, fn ) {
return typeof delay === "number" ?
this.each(function() {
var elem = this;
setTimeout(function() {
$( elem ).focus();
if ( fn ) {
fn.call( elem );
}
}, delay );
}) :
orig.apply( this, arguments );
};
})( $.fn.focus ),
scrollParent: function() {
var scrollParent;
if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
scrollParent = this.parents().filter(function() {
return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
}).eq(0);
} else {
scrollParent = this.parents().filter(function() {
return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
}).eq(0);
}
return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
},
uniqueId: function() {
return this.each(function() {
if ( !this.id ) {
this.id = "ui-id-" + (++uuid);
}
});
},
removeUniqueId: function() {
return this.each(function() {
if ( runiqueId.test( this.id ) ) {
$( this ).removeAttr( "id" );
}
});
}
});
// selectors
function focusable( element, isTabIndexNotNaN ) {
var map, mapName, img,
nodeName = element.nodeName.toLowerCase();
if ( "area" === nodeName ) {
map = element.parentNode;
mapName = map.name;
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
return false;
}
img = $( "img[usemap=#" + mapName + "]" )[0];
return !!img && visible( img );
}
return ( /input|select|textarea|button|object/.test( nodeName ) ?
!element.disabled :
"a" === nodeName ?
element.href || isTabIndexNotNaN :
isTabIndexNotNaN) &&
// the element and all of its ancestors must be visible
visible( element );
}
function visible( element ) {
return $.expr.filters.visible( element ) &&
!$( element ).parents().addBack().filter(function() {
return $.css( this, "visibility" ) === "hidden";
}).length;
}
$.extend( $.expr[ ":" ], {
data: $.expr.createPseudo ?
$.expr.createPseudo(function( dataName ) {
return function( elem ) {
return !!$.data( elem, dataName );
};
}) :
// support: jQuery <1.8
function( elem, i, match ) {
return !!$.data( elem, match[ 3 ] );
},
focusable: function( element ) {
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
},
tabbable: function( element ) {
var tabIndex = $.attr( element, "tabindex" ),
isTabIndexNaN = isNaN( tabIndex );
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
}
});
// support: jQuery <1.8
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
$.each( [ "Width", "Height" ], function( i, name ) {
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
type = name.toLowerCase(),
orig = {
innerWidth: $.fn.innerWidth,
innerHeight: $.fn.innerHeight,
outerWidth: $.fn.outerWidth,
outerHeight: $.fn.outerHeight
};
function reduce( elem, size, border, margin ) {
$.each( side, function() {
size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
if ( border ) {
size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
}
if ( margin ) {
size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
}
});
return size;
}
$.fn[ "inner" + name ] = function( size ) {
if ( size === undefined ) {
return orig[ "inner" + name ].call( this );
}
return this.each(function() {
$( this ).css( type, reduce( this, size ) + "px" );
});
};
$.fn[ "outer" + name] = function( size, margin ) {
if ( typeof size !== "number" ) {
return orig[ "outer" + name ].call( this, size );
}
return this.each(function() {
$( this).css( type, reduce( this, size, true, margin ) + "px" );
});
};
});
}
// support: jQuery <1.8
if ( !$.fn.addBack ) {
$.fn.addBack = function( selector ) {
return this.add( selector == null ?
this.prevObject : this.prevObject.filter( selector )
);
};
}
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
$.fn.removeData = (function( removeData ) {
return function( key ) {
if ( arguments.length ) {
return removeData.call( this, $.camelCase( key ) );
} else {
return removeData.call( this );
}
};
})( $.fn.removeData );
}
// deprecated
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
$.support.selectstart = "onselectstart" in document.createElement( "div" );
$.fn.extend({
disableSelection: function() {
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
".ui-disableSelection", function( event ) {
event.preventDefault();
});
},
enableSelection: function() {
return this.unbind( ".ui-disableSelection" );
},
zIndex: function( zIndex ) {
if ( zIndex !== undefined ) {
return this.css( "zIndex", zIndex );
}
if ( this.length ) {
var elem = $( this[ 0 ] ), position, value;
while ( elem.length && elem[ 0 ] !== document ) {
// Ignore z-index if position is set to a value where z-index is ignored by the browser
// This makes behavior of this function consistent across browsers
// WebKit always returns auto if the element is positioned
position = elem.css( "position" );
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
// IE returns 0 when zIndex is not specified
// other browsers return a string
// we ignore the case of nested elements with an explicit value of 0
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
value = parseInt( elem.css( "zIndex" ), 10 );
if ( !isNaN( value ) && value !== 0 ) {
return value;
}
}
elem = elem.parent();
}
}
return 0;
}
});
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
$.ui.plugin = {
add: function( module, option, set ) {
var i,
proto = $.ui[ module ].prototype;
for ( i in set ) {
proto.plugins[ i ] = proto.plugins[ i ] || [];
proto.plugins[ i ].push( [ option, set[ i ] ] );
}
},
call: function( instance, name, args, allowDisconnected ) {
var i,
set = instance.plugins[ name ];
if ( !set ) {
return;
}
if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
return;
}
for ( i = 0; i < set.length; i++ ) {
if ( instance.options[ set[ i ][ 0 ] ] ) {
set[ i ][ 1 ].apply( instance.element, args );
}
}
}
};
})( jQuery );
(function( $, window, undefined ) {
// jQuery.mobile configurable options
$.extend($.mobile, {
// define the window and the document objects
window: $( window ),
document: $( document ),
//TODO: Remove once we pull in UI Core
keyCode: $.ui.keyCode,
// Place to store various widget extensions
behaviors: {},
// Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
silentScroll: function( ypos ) {
if ( $.type( ypos ) !== "number" ) {
ypos = $.mobile.defaultHomeScroll;
}
// prevent scrollstart and scrollstop events
$.event.special.scrollstart.enabled = false;
setTimeout( function() {
window.scrollTo( 0, ypos );
$.mobile.document.trigger( "silentscroll", { x: 0, y: ypos });
}, 20 );
setTimeout( function() {
$.event.special.scrollstart.enabled = true;
}, 150 );
},
// DEPRECATED in 1.4
// Find the closest parent with a theme class on it. Note that
// we are not using $.fn.closest() on purpose here because this
// method gets called quite a bit and we need it to be as fast
// as possible.
getInheritedTheme: function( el, defaultTheme ) {
var e = el[ 0 ],
ltr = "",
re = /ui-(bar|body|overlay)-([a-z])\b/,
c, m;
while ( e ) {
c = e.className || "";
if ( c && ( m = re.exec( c ) ) && ( ltr = m[ 2 ] ) ) {
// We found a parent with a theme class
// on it so bail from this loop.
break;
}
e = e.parentNode;
}
// Return the theme letter we found, if none, return the
// specified default.
return ltr || defaultTheme || "a";
},
// TODO the following $ and $.fn extensions can/probably should be moved into jquery.mobile.core.helpers
//
enhanceable: function( $set ) {
return this.haveParents( $set, "enhance" );
},
hijackable: function( $set ) {
return this.haveParents( $set, "ajax" );
},
haveParents: function( $set, attr ) {
if ( !$.mobile.ignoreContentEnabled ) {
return $set;
}
var count = $set.length,
$newSet = $(),
e, $element, excluded,
i, c;
for ( i = 0; i < count; i++ ) {
$element = $set.eq( i );
excluded = false;
e = $set[ i ];
while ( e ) {
c = e.getAttribute ? e.getAttribute( "data-" + $.mobile.ns + attr ) : "";
if ( c === "false" ) {
excluded = true;
break;
}
e = e.parentNode;
}
if ( !excluded ) {
$newSet = $newSet.add( $element );
}
}
return $newSet;
},
getScreenHeight: function() {
// Native innerHeight returns more accurate value for this across platforms,
// jQuery version is here as a normalized fallback for platforms like Symbian
return window.innerHeight || $.mobile.window.height();
},
//simply set the active page's minimum height to screen height, depending on orientation
resetActivePageHeight: function( height ) {
var aPage = $( "." + $.mobile.activePageClass ),
aPageHeight = aPage.height(),
aPageOuterHeight = aPage.outerHeight( true );
height = ( typeof height === "number" ) ? height : $.mobile.getScreenHeight();
aPage.css( "min-height", height - ( aPageOuterHeight - aPageHeight ) );
}
});
$.fn.removeWithDependents = function() {
$.removeWithDependents( this );
};
$.removeWithDependents = function( elem ) {
var $elem = $( elem );
( $elem.jqmData( "dependents" ) || $() ).remove();
$elem.remove();
};
$.fn.addDependents = function( newDependents ) {
$.addDependents( this , newDependents );
};
$.addDependents = function( elem, newDependents ) {
var $elem = $( elem ),
dependents = $elem.jqmData( "dependents" ) || $();
$elem.jqmData( "dependents", $( dependents ).add( newDependents ) );
};
// note that this helper doesn't attempt to handle the callback
// or setting of an html element's text, its only purpose is
// to return the html encoded version of the text in all cases. (thus the name)
$.fn.getEncodedText = function() {
return $( "<a>" ).text( $( this ).text() ).html();
};
// fluent helper function for the mobile namespaced equivalent
$.fn.jqmEnhanceable = function() {
return $.mobile.enhanceable( this );
};
$.fn.jqmHijackable = function() {
return $.mobile.hijackable( this );
};
$.find.matches = function( expr, set ) {
return $.find( expr, null, null, set );
};
$.find.matchesSelector = function( node, expr ) {
return $.find( expr, null, null, [ node ] ).length > 0;
};
})( jQuery, this );
/*!
* jQuery UI Widget 1.10.1
* http://jqueryui.com
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/jQuery.widget/
*/
(function( $, undefined ) {
var uuid = 0,
slice = Array.prototype.slice,
_cleanData = $.cleanData;
$.cleanData = function( elems ) {
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
try {
$( elem ).triggerHandler( "remove" );
// http://bugs.jquery.com/ticket/8235
} catch( e ) {}
}
_cleanData( elems );
};
$.widget = function( name, base, prototype ) {
var fullName, existingConstructor, constructor, basePrototype,
// proxiedPrototype allows the provided prototype to remain unmodified
// so that it can be used as a mixin for multiple widgets (#8876)
proxiedPrototype = {},
namespace = name.split( "." )[ 0 ];
name = name.split( "." )[ 1 ];
fullName = namespace + "-" + name;
if ( !prototype ) {
prototype = base;
base = $.Widget;
}
// create selector for plugin
$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
return !!$.data( elem, fullName );
};
$[ namespace ] = $[ namespace ] || {};
existingConstructor = $[ namespace ][ name ];
constructor = $[ namespace ][ name ] = function( options, element ) {
// allow instantiation without "new" keyword
if ( !this._createWidget ) {
return new constructor( options, element );
}
// allow instantiation without initializing for simple inheritance
// must use "new" keyword (the code above always passes args)
if ( arguments.length ) {
this._createWidget( options, element );
}
};
// extend with the existing constructor to carry over any static properties
$.extend( constructor, existingConstructor, {
version: prototype.version,
// copy the object used to create the prototype in case we need to
// redefine the widget later
_proto: $.extend( {}, prototype ),
// track widgets that inherit from this widget in case this widget is
// redefined after a widget inherits from it
_childConstructors: []
});
basePrototype = new base();
// we need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
basePrototype.options = $.widget.extend( {}, basePrototype.options );
$.each( prototype, function( prop, value ) {
if ( !$.isFunction( value ) ) {
proxiedPrototype[ prop ] = value;
return;
}
proxiedPrototype[ prop ] = (function() {
var _super = function() {
return base.prototype[ prop ].apply( this, arguments );
},
_superApply = function( args ) {
return base.prototype[ prop ].apply( this, args );
};
return function() {
var __super = this._super,
__superApply = this._superApply,
returnValue;
this._super = _super;
this._superApply = _superApply;
returnValue = value.apply( this, arguments );
this._super = __super;
this._superApply = __superApply;
return returnValue;
};
})();
});
constructor.prototype = $.widget.extend( basePrototype, {
// TODO: remove support for widgetEventPrefix
// always use the name + a colon as the prefix, e.g., draggable:start
// don't prefix for widgets that aren't DOM-based
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
}, proxiedPrototype, {
constructor: constructor,
namespace: namespace,
widgetName: name,
widgetFullName: fullName
});
// If this widget is being redefined then we need to find all widgets that
// are inheriting from it and redefine all of them so that they inherit from
// the new version of this widget. We're essentially trying to replace one
// level in the prototype chain.
if ( existingConstructor ) {
$.each( existingConstructor._childConstructors, function( i, child ) {
var childPrototype = child.prototype;
// redefine the child widget using the same prototype that was
// originally used, but inherit from the new version of the base
$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
});
// remove the list of existing child constructors from the old constructor
// so the old child constructors can be garbage collected
delete existingConstructor._childConstructors;
} else {
base._childConstructors.push( constructor );
}
$.widget.bridge( name, constructor );
};
$.widget.extend = function( target ) {
var input = slice.call( arguments, 1 ),
inputIndex = 0,
inputLength = input.length,
key,
value;
for ( ; inputIndex < inputLength; inputIndex++ ) {
for ( key in input[ inputIndex ] ) {
value = input[ inputIndex ][ key ];
if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
// Clone objects
if ( $.isPlainObject( value ) ) {
target[ key ] = $.isPlainObject( target[ key ] ) ?
$.widget.extend( {}, target[ key ], value ) :
// Don't extend strings, arrays, etc. with objects
$.widget.extend( {}, value );
// Copy everything else by reference
} else {
target[ key ] = value;
}
}
}
}
return target;
};
$.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string",
args = slice.call( arguments, 1 ),
returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
$.widget.extend.apply( null, [ options ].concat(args) ) :
options;
if ( isMethodCall ) {
this.each(function() {
var methodValue,
instance = $.data( this, fullName );
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
}
if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
return $.error( "no such method '" + options + "' for " + name + " widget instance" );
}
methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue && methodValue.jquery ?
returnValue.pushStack( methodValue.get() ) :
methodValue;
return false;
}
});
} else {
this.each(function() {
var instance = $.data( this, fullName );
if ( instance ) {
instance.option( options || {} )._init();
} else {
$.data( this, fullName, new object( options, this ) );
}
});
}
return returnValue;
};
};
$.Widget = function( /* options, element */ ) {};
$.Widget._childConstructors = [];
$.Widget.prototype = {
widgetName: "widget",
widgetEventPrefix: "",
defaultElement: "<div>",
options: {
disabled: false,
// callbacks
create: null
},
_createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element );
this.uuid = uuid++;
this.eventNamespace = "." + this.widgetName + this.uuid;
this.options = $.widget.extend( {},
this.options,
this._getCreateOptions(),
options );
this.bindings = $();
this.hoverable = $();
this.focusable = $();
if ( element !== this ) {
$.data( element, this.widgetFullName, this );
this._on( true, this.element, {
remove: function( event ) {
if ( event.target === element ) {
this.destroy();
}
}
});
this.document = $( element.style ?
// element within the document
element.ownerDocument :
// element is window or document
element.document || element );
this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
}
this._create();
this._trigger( "create", null, this._getCreateEventData() );
this._init();
},
_getCreateOptions: $.noop,
_getCreateEventData: $.noop,
_create: $.noop,
_init: $.noop,
destroy: function() {
this._destroy();
// we can probably remove the unbind calls in 2.0
// all event bindings should go through this._on()
this.element
.unbind( this.eventNamespace )
// 1.9 BC for #7810
// TODO remove dual storage
.removeData( this.widgetName )
.removeData( this.widgetFullName )
// support: jquery <1.6.3
// http://bugs.jquery.com/ticket/9413
.removeData( $.camelCase( this.widgetFullName ) );
this.widget()
.unbind( this.eventNamespace )
.removeAttr( "aria-disabled" )
.removeClass(
this.widgetFullName + "-disabled " +
"ui-state-disabled" );
// clean up events and states
this.bindings.unbind( this.eventNamespace );
this.hoverable.removeClass( "ui-state-hover" );
this.focusable.removeClass( "ui-state-focus" );
},
_destroy: $.noop,
widget: function() {
return this.element;
},
option: function( key, value ) {
var options = key,
parts,
curOption,
i;
if ( arguments.length === 0 ) {
// don't return a reference to the internal hash
return $.widget.extend( {}, this.options );
}
if ( typeof key === "string" ) {
// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
options = {};
parts = key.split( "." );
key = parts.shift();
if ( parts.length ) {
curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
for ( i = 0; i < parts.length - 1; i++ ) {
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
curOption = curOption[ parts[ i ] ];
}
key = parts.pop();
if ( value === undefined ) {
return curOption[ key ] === undefined ? null : curOption[ key ];
}
curOption[ key ] = value;
} else {
if ( value === undefined ) {
return this.options[ key ] === undefined ? null : this.options[ key ];
}
options[ key ] = value;
}
}
this._setOptions( options );
return this;
},
_setOptions: function( options ) {
var key;
for ( key in options ) {
this._setOption( key, options[ key ] );
}
return this;
},
_setOption: function( key, value ) {
this.options[ key ] = value;
if ( key === "disabled" ) {
this.widget()
.toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
.attr( "aria-disabled", value );
this.hoverable.removeClass( "ui-state-hover" );
this.focusable.removeClass( "ui-state-focus" );
}
return this;
},
enable: function() {
return this._setOption( "disabled", false );
},
disable: function() {
return this._setOption( "disabled", true );
},
_on: function( suppressDisabledCheck, element, handlers ) {
var delegateElement,
instance = this;
// no suppressDisabledCheck flag, shuffle arguments
if ( typeof suppressDisabledCheck !== "boolean" ) {
handlers = element;
element = suppressDisabledCheck;
suppressDisabledCheck = false;
}
// no element argument, shuffle and use this.element
if ( !handlers ) {
handlers = element;
element = this.element;
delegateElement = this.widget();
} else {
// accept selectors, DOM elements
element = delegateElement = $( element );
this.bindings = this.bindings.add( element );
}
$.each( handlers, function( event, handler ) {
function handlerProxy() {
// allow widgets to customize the disabled handling
// - disabled as an array instead of boolean
// - disabled class as method for disabling individual parts
if ( !suppressDisabledCheck &&
( instance.options.disabled === true ||
$( this ).hasClass( "ui-state-disabled" ) ) ) {
return;
}
return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );
}
// copy the guid so direct unbinding works
if ( typeof handler !== "string" ) {
handlerProxy.guid = handler.guid =
handler.guid || handlerProxy.guid || $.guid++;
}
var match = event.match( /^(\w+)\s*(.*)$/ ),
eventName = match[1] + instance.eventNamespace,
selector = match[2];
if ( selector ) {
delegateElement.delegate( selector, eventName, handlerProxy );
} else {
element.bind( eventName, handlerProxy );
}
});
},
_off: function( element, eventName ) {
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
element.unbind( eventName ).undelegate( eventName );
},
_delay: function( handler, delay ) {
function handlerProxy() {
return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );
}
var instance = this;
return setTimeout( handlerProxy, delay || 0 );
},
_hoverable: function( element ) {
this.hoverable = this.hoverable.add( element );
this._on( element, {
mouseenter: function( event ) {
$( event.currentTarget ).addClass( "ui-state-hover" );
},
mouseleave: function( event ) {
$( event.currentTarget ).removeClass( "ui-state-hover" );
}
});
},
_focusable: function( element ) {
this.focusable = this.focusable.add( element );
this._on( element, {
focusin: function( event ) {
$( event.currentTarget ).addClass( "ui-state-focus" );
},
focusout: function( event ) {
$( event.currentTarget ).removeClass( "ui-state-focus" );
}
});
},
_trigger: function( type, event, data ) {
var prop, orig,
callback = this.options[ type ];
data = data || {};
event = $.Event( event );
event.type = ( type === this.widgetEventPrefix ?
type :
this.widgetEventPrefix + type ).toLowerCase();
// the original event may come from any element
// so we need to reset the target on the new event
event.target = this.element[ 0 ];
// copy original event properties over to the new event
orig = event.originalEvent;
if ( orig ) {
for ( prop in orig ) {
if ( !( prop in event ) ) {
event[ prop ] = orig[ prop ];
}
}
}
this.element.trigger( event, data );
return !( $.isFunction( callback ) &&
callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
event.isDefaultPrevented() );
}
};
$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
if ( typeof options === "string" ) {
options = { effect: options };
}
var hasOptions,
effectName = !options ?
method :
options === true || typeof options === "number" ?
defaultEffect :
options.effect || defaultEffect;
options = options || {};
if ( typeof options === "number" ) {
options = { duration: options };
}
hasOptions = !$.isEmptyObject( options );
options.complete = callback;
if ( options.delay ) {
element.delay( options.delay );
}
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
element[ method ]( options );
} else if ( effectName !== method && element[ effectName ] ) {
element[ effectName ]( options.duration, options.easing, callback );
} else {
element.queue(function( next ) {
$( this )[ method ]();
if ( callback ) {
callback.call( element[ 0 ] );
}
next();
});
}
};
});
})( jQuery );
(function( $, undefined ) {
$.extend( $.Widget.prototype, {
_getCreateOptions: function() {
var elem = this.element,
options = {};
$.each( this.options, function( option ) {
var value = $.mobile.getAttribute( elem[ 0 ], option.replace( /[A-Z]/g, function( c ) {
return "-" + c.toLowerCase();
}), true );
if ( value != null ) {
options[ option ] = value;
}
});
return options;
},
enhanceWithin: function( target, useKeepNative ) {
this.enhance( $( $[ this.namespace ][ this.widgetName ].initSelector, $( target ) ), useKeepNative );
},
enhance: function( targets, useKeepNative ) {
var page, keepNative, $widgetElements = $( targets );
// if ignoreContentEnabled is set to true the framework should
// only enhance the selected elements when they do NOT have a
// parent with the data-namespace-ignore attribute
$widgetElements = $.mobile.enhanceable( $widgetElements );
if ( useKeepNative && $widgetElements.length ) {
// TODO remove dependency on the page widget for the keepNative.
// Currently the keepNative value is defined on the page prototype so
// the method is as well
page = $.mobile.closestPageData( $widgetElements );
keepNative = ( page && page.keepNativeSelector()) || "";
$widgetElements = $widgetElements.not( keepNative );
}
$widgetElements[ this.widgetName ]();
}
});
//TODO: Remove in 1.5 for backcompat only
$.mobile.widget = $.Widget;
})( jQuery );
(function( $, undefined ) {
var doc = $( document );
$.mobile._Enhancer = function() {
this._dependencies = {};
};
$.extend( $.mobile._Enhancer.prototype, {
_defaultCallback: function( widget ) {
var parts = widget.split( "." ),
ns = parts[ 0 ],
name = parts[ 1 ],
ret = function( targetEl ) {
// First try to grab the initSelector from the old location in case
// some legacy code modified it. If not, grab it from the new location.
var targets = $( $[ ns ][ name ].prototype.options.initSelector ||
$[ ns ][ name ].initSelector, targetEl );
if ( targets.length ) {
$[ ns ][ name ].prototype.enhance( targets, true );
}
};
return ret;
},
add: function( widget, widgetDeps, callback ) {
var deps = this._dependencies;
if ( !widgetDeps ) {
widgetDeps = { dependencies: [] };
}
if ( !callback ) {
callback = this._defaultCallback( widget );
}
deps[ widget ] = {
deps: widgetDeps.dependencies,
callback: callback
};
return this;
},
_enhance: function( el, idx, visited ) {
var depIdx,
dep = this._dependencies[ idx ];
if ( dep && !visited[ idx ] ) {
for ( depIdx in dep.deps ) {
this._enhance( el, dep.deps[ depIdx ], visited );
}
dep.callback( el );
visited[ idx ] = true;
}
},
enhance: function( targetEl ) {
var idx,
visited = {},
deps = this._dependencies;
for ( idx in deps ) {
this._enhance( targetEl, idx, visited );
}
return this;
}
});
$.mobile._enhancer = new $.mobile._Enhancer();
// Support triggering "create" on an element
doc.bind( "create", function( e ) {
$.mobile._enhancer.enhance( e.target );
});
})( jQuery );
(function( $, undefined ) {
$.widget( "mobile.page", {
options: {
theme: "a",
domCache: false,
keepNativeDefault: ":jqmData(role='none'), :jqmData(role='nojs')",
contentTheme: null
},
// DEPRECATED for > 1.4
// TODO remove at 1.5
_createWidget: function() {
$.Widget.prototype._createWidget.apply( this, arguments );
this._trigger( "init" );
},
_create: function() {
var attrPrefix = "data-" + $.mobile.ns,
self = this;
// if false is returned by the callbacks do not create the page
if ( this._trigger( "beforecreate" ) === false ) {
return false;
}
if ( this.options.role ) {
this.element.attr( "data-" + $.mobile.ns + "role", this.options.role );
}
this.element
.attr( "tabindex", "0" )
.addClass( "ui-page ui-page-theme-" + this.options.theme );
this._on( this.element, {
pagebeforehide: "removeContainerBackground",
pagebeforeshow: "_handlePageBeforeShow"
});
this.element.find( "[" + attrPrefix + "role='content']" ).each( function() {
var $this = $( this ),
theme = this.getAttribute( attrPrefix + "theme" ) || undefined;
self.options.contentTheme = theme || self.options.contentTheme || ( self.element.jqmData("role") === "dialog" && self.options.theme );
$this.addClass( "ui-content" );
if ( self.options.contentTheme ) {
$this.addClass( "ui-body-" + ( self.options.contentTheme ) );
}
// Add ARIA role
$this.attr( "role", "main" ).addClass( "ui-content" );
});
// enhance the page
$.mobile._enhancer.enhance( this.element[ 0 ] );
},
bindRemove: function( callback ) {
var page = this.element;
// when dom caching is not enabled or the page is embedded bind to remove the page on hide
if ( !page.data( "mobile-page" ).options.domCache &&
page.is( ":jqmData(external-page='true')" ) ) {
// TODO use _on - that is, sort out why it doesn't work in this case
page.bind( "pagehide.remove", callback || function(/* e */) {
var $this = $( this ),
prEvent = new $.Event( "pageremove" );
$this.trigger( prEvent );
if ( !prEvent.isDefaultPrevented() ) {
$this.removeWithDependents();
}
});
}
},
_setOptions: function( o ) {
if( o.theme !== undefined ) {
this.element.removeClass( "ui-body-" + this.options.theme ).addClass( "ui-body-" + o.theme );
}
if( o.contentTheme !== undefined ) {
this.element.find( "[data-" + $.mobile.ns + "='content']" ).removeClass( "ui-body-" + this.options.contentTheme )
.addClass( "ui-body-" + o.contentTheme );
}
},
_handlePageBeforeShow: function(/* e */) {
this.setContainerBackground();
},
removeContainerBackground: function() {
var classes = ( $.mobile.pageContainer.attr( "class" ) || "" ).split( " " ),
overlayTheme = null,
matches;
while ( classes.length > 0 ) {
overlayTheme = classes.pop();
matches = ( new RegExp( "^ui-overlay-([a-z])$" ) ).exec( overlayTheme );
if ( matches && matches.length > 1 ) {
overlayTheme = matches[ 1 ];
break;
} else {
overlayTheme = null;
}
}
$.mobile.pageContainer.removeClass( "ui-overlay-" + overlayTheme );
},
// set the page container background to the page theme
setContainerBackground: function( theme ) {
if ( this.options.theme ) {
$.mobile.pageContainer.addClass( "ui-overlay-" + ( theme || this.options.theme ) );
}
},
keepNativeSelector: function() {
var options = this.options,
keepNativeDefined = options.keepNative && $.trim( options.keepNative );
if ( keepNativeDefined && options.keepNative !== options.keepNativeDefault ) {
return [options.keepNative, options.keepNativeDefault].join( ", " );
}
return options.keepNativeDefault;
}
});
})( jQuery );
// ========================================================================
// template for functions
/*
(function( $, window, undefined ) {
$.rjs.foo = function() {
this.init.apply(this, arguments);
};
$.extend($.rjs.foo.prototype, {
someClass: " ui-foo",
someFunction: function( name, reverse, $to, $from ) {
$.extend(this, {
name: name,
reverse: reverse,
$to: $to,
$from: $from,
deferred: new $.Deferred()
});
},
usw: function(...)
*/
// initializer
(function( $, window, undefined ) {
var $html = $( "html" );
//remove initial build class (only present on first pageshow)
function hideRenderingClass() {
$html.removeClass( "ui-rjs-rendering" );
}
// trigger mobileinit event - useful hook for configuring $.rjs settings before they're used
$( window.document ).trigger( "renderinit" );
// Add rjs, initial load "rendering" classes to docEl
$html.addClass( "ui-rjs ui-rjs-rendering" );
// This is a fallback. If anything goes wrong (JS errors, etc), or events don't fire,
// this ensures the rendering class is removed after 5 seconds, so content is visible and accessible
setTimeout( hideRenderingClass, 5000 );
$.extend( $.rjs, {
// find and enhance the gadgets in the dom
initialize: function() {
// find present pages
var $gadgets = $( ":rjsData(gadget='true')" );
if ( !$gadgets.length ) {
// what do we do here
}
// initialize navigation events now, after mobileinit has occurred and the page container
// has been created but before the rest of the library is alerted to that fact
$.rjs.rjsReadyDeferred.resolve();
//remove initial build class (only present on first page)
hideRenderingClass();
// retrieve intial hash config
if ( /* we are passed a rjs configuration */ ) {
}
// do something with the gadgets found (this used to be pages!)
// maybe model gadget after pages
}
});
}( jQuery, this ));
}));
/*! RenderJs v0.2 */
/*global $, jQuery, localStorage, jIO, window, document, DOMParser */
/*jslint evil: true, indent: 2, maxerr: 3, maxlen: 79 */
"use strict";
/*
* renderJs - Generic Gadget library renderer.
* http://www.renderjs.org/documentation
*/
(function (document, window, $, DOMParser) {
var gadget_model_dict = {},
gadget_scope_dict = {},
javascript_registration_dict = {},
stylesheet_registration_dict = {},
gadget_loading_klass,
methods,
loading_gadget_promise,
renderJS;
function RenderJSGadget() {}
RenderJSGadget.prototype.title = "";
RenderJSGadget.prototype.interface_list = [];
RenderJSGadget.prototype.path = "";
RenderJSGadget.prototype.html = "";
RenderJSGadget.prototype.required_css_list = [];
RenderJSGadget.prototype.required_js_list = [];
RenderJSGadget.ready_list = [];
RenderJSGadget.ready = function (callback) {
this.ready_list.push(callback);
};
RenderJSGadget.declareMethod = function (name, callback) {
// // Register the potentially loading javascript
// var script_element = $('script').last(),
// src = script_element.attr('src');
// if (src !== undefined) {
// if (javascript_registration_dict[src] === undefined) {
// // First time loading the JS file.
// // Remember all declareMethod calls
// javascript_registration_dict[src] = {
// loaded: false,
// method_list: [[name, callback]],
// };
// script_element.load(function () {
// javascript_registration_dict[src].loaded = true;
// });
// } else if (!javascript_registration_dict[src].loaded) {
// javascript_registration_dict[src].method_list.push([name, callback]);
// }
// }
this.prototype[name] = function () {
var dfr = $.Deferred(),
gadget = this;
$.when(callback.apply(this, arguments))
.done(function () {
dfr.resolveWith(gadget, arguments);
})
.fail(function () {
dfr.rejectWith(gadget, arguments);
});
return dfr.promise();
};
// Allow chain
return this;
};
RenderJSGadget
.declareMethod('getInterfaceList', function () {
// Returns the list of gadget prototype
return this.interface_list;
})
.declareMethod('getRequiredCSSList', function () {
// Returns a list of CSS required by the gadget
return this.required_css_list;
})
.declareMethod('getRequiredJSList', function () {
// Returns a list of JS required by the gadget
return this.required_js_list;
})
.declareMethod('getPath', function () {
// Returns the path of the code of a gadget
return this.path;
})
.declareMethod('getTitle', function () {
// Returns the title of a gadget
return this.title;
})
.declareMethod('getHTML', function () {
// Returns the HTML of a gadget
return this.html;
});
RenderJSGadget.prototype.declareGadget = function (url, jquery_context) {
var loaded = false,
previous_loading_gadget_promise = loading_gadget_promise,
next_loading_gadget_deferred = $.Deferred(),
dfr = $.Deferred(),
dfr_promise = dfr.promise();
dfr_promise.done(function (created_gadget) {
created_gadget.context.html(created_gadget.constructor.prototype.html);
$.each(created_gadget.constructor.ready_list, function (i, callback) {
callback.apply(created_gadget);
});
});
loading_gadget_promise = next_loading_gadget_deferred.promise();
if (gadget_model_dict.hasOwnProperty(url)) {
loaded = true;
}
renderJS.declareGadgetKlass(url).done(function (Klass) {
var gadget = new Klass();
gadget.context = jquery_context;
if (loaded === false) {
$.when(gadget.getRequiredJSList(), gadget.getRequiredCSSList())
.done(function (js_list, css_list) {
previous_loading_gadget_promise.done(function () {
var result_list = [];
gadget_loading_klass = Klass;
$.each(js_list, function (i, required_url) {
result_list.push(renderJS.declareJS(required_url));
});
$.each(css_list, function (i, required_url) {
result_list.push(renderJS.declareCSS(required_url));
});
$.when.apply(this, result_list).done(function () {
dfr.resolve(gadget);
}).fail(function () {
dfr.reject(gadget);
});
});
}).fail(function () {
dfr.reject(gadget);
});
} else {
dfr.resolve(gadget);
}
}).fail(function () {
dfr.reject();
});
dfr_promise.then(function () {
gadget_loading_klass = undefined;
next_loading_gadget_deferred.resolve();
});
return dfr_promise;
};
methods = {
loadGadgetFromDom: function () {
$(this).find('[data-gadget-path]').each(function (index, value) {
$(this).renderJS('declareGadget', $(this).attr('data-gadget-path'), {
scope: $(this).attr('data-gadget-scope'),
})
.done(function (value) {
var parsed_xml;
// Check that context is still attached to the DOM
// XXX Usefull?
if ($(this).closest(document.body).length) {
parsed_xml = $($.parseXML(value));
// Inject the css
// XXX Manage relative URL
$.each(parsed_xml.find('link[rel=stylesheet]'),
function (i, link) {
$('head').append(
'<link rel="stylesheet" href="' +
$(link).attr('href') +
'" type="text/css" />'
);
});
// Inject the js
// XXX Manage relative URL
$.each(parsed_xml.find('script[type="text/javascript"]'),
function (i, script) {
// $('head').append(
// '<script type="text/javascript" href="' +
// $(script).attr('src') +
// '" />'
// );
// Prevent infinite recursion if loading render.js
// more than once
if ($('head').find('script[src="' + $(script).attr('src')
+ '"]').length === 0) {
var headID = document.getElementsByTagName("head")[0],
newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = $(script).attr('src');
headID.appendChild(newScript);
}
});
// Inject the html
// XXX parseXML does not support <div /> (without 2 tags)
$(this).html(parsed_xml.find('body').clone());
// XXX No idea why it is required to make it work
// Probably because of parseXML
$(this).html($(this).html())
.renderJS('loadGadgetFromDom');
}
});
});
},
};
// // Define a local copy of renderJS
// renderJS = function (selector) {
// // The renderJS object is actually just the init constructor 'enhanced'
// return new renderJS.fn.init(selector, rootrenderJS);
// };
// renderJS.fn = renderJS.prototype = {
// constructor: renderJS,
// init: function (selector, rootrenderJS) {
// var result;
// // HANDLE: $(""), $(null), $(undefined), $(false)
// if (!selector) {
// console.log("no selector");
// result = this;
// // // HANDLE: $(DOMElement)
// // } else if (selector.nodeType) {
// // this.context = this[0] = selector;
// // this.length = 1;
// // result = this;
// // } else if (selector === this) {
// // result = this.constructor();
// } else {
// // throw new Error("Not implemented selector " + selector);
// result = this.constructor();
// }
// return result;
// },
// };
// // Give the init function the renderJS prototype for later instantiation
// renderJS.fn.init.prototype = renderJS.fn;
//
// jQuery.fn.extend({
// attr: function (name, value) {
// return jQuery.access(this, jQuery.attr, name, value,
// arguments.length > 1);
// },
// });
renderJS = function (selector) {
var result;
// if (selector.nodeType) {
// console.log(selector);
// } else {
if (selector === window) {
// window is the this value when loading a javascript file
// In this case, use the current loading gadget constructor
result = gadget_loading_klass;
// } else if ($.isFunction(selector)) {
// console.log(selector);
} else if (selector instanceof RenderJSGadget) {
result = selector;
}
if (result === undefined) {
console.error(selector);
throw new Error("Unknown selector '" + selector + "'");
}
return result;
};
renderJS.declareJS = function (url) {
// // Prevent infinite recursion if loading render.js
// // more than once
// if ($('head').find('script[src="' + $(script).attr('src')
// + '"]').length === 0) {
// var headID = document.getElementsByTagName("head")[0],
// newScript = document.createElement('script');
// newScript.type = 'text/javascript';
// newScript.src = $(script).attr('src');
// headID.appendChild(newScript);
// }
var dfr,
origin_dfr;
if (javascript_registration_dict.hasOwnProperty(url)) {
origin_dfr = $.Deferred();
setTimeout(function () {
origin_dfr.resolve();
});
dfr = origin_dfr.promise();
} else {
dfr = $.ajax({
url: url,
dataType: "script",
cache: true,
}).done(function (script, textStatus) {
javascript_registration_dict[url] = null;
});
}
return dfr;
};
renderJS.declareCSS = function (url) {
// https://github.com/furf/jquery-getCSS/blob/master/jquery.getCSS.js
var origin_dfr = $.Deferred(),
head,
link;
if (stylesheet_registration_dict.hasOwnProperty(url)) {
setTimeout(function () {
origin_dfr.resolve();
});
} else {
head = document.getElementsByTagName('head')[0];
link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url;
origin_dfr.done(function () {
stylesheet_registration_dict[url] = null;
});
head.appendChild(link);
setTimeout(function () {
origin_dfr.resolve();
});
}
return origin_dfr.promise();
};
renderJS.declareGadgetKlass = function (url) {
var dfr = $.Deferred(),
parsed_html;
if (gadget_model_dict.hasOwnProperty(url)) {
dfr.resolve(gadget_model_dict[url]);
} else {
$.ajax(url)
.done(function (value, textStatus, jqXHR) {
var klass, tmp_constructor, key;
if ((jqXHR.getResponseHeader("Content-Type") || "")
=== 'text/html') {
try {
if (!gadget_model_dict.hasOwnProperty(url)) {
// Class inheritance
tmp_constructor = function () {
RenderJSGadget.call(this);
};
tmp_constructor.ready_list = [];
tmp_constructor.declareMethod =
RenderJSGadget.declareMethod;
tmp_constructor.ready =
RenderJSGadget.ready;
tmp_constructor.prototype = new RenderJSGadget();
tmp_constructor.prototype.constructor = tmp_constructor;
tmp_constructor.prototype.path = url;
parsed_html = renderJS.parseGadgetHTML(value);
for (key in parsed_html) {
if (parsed_html.hasOwnProperty(key)) {
tmp_constructor.prototype[key] = parsed_html[key];
}
}
gadget_model_dict[url] = tmp_constructor;
}
dfr.resolve(gadget_model_dict[url]);
} catch (e) {
dfr.reject(jqXHR, "HTML Parsing failed");
}
} else {
dfr.reject(jqXHR, "Unexpected content type");
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
dfr.reject(jqXHR, textStatus, errorThrown);
});
}
return dfr.promise();
};
// For test purpose only
renderJS.clearGadgetKlassList = function () {
gadget_model_dict = {};
};
renderJS.parseGadgetHTML = function (html) {
var parsed_xml,
result,
settings = {
title: "",
interface_list: [],
html: "",
required_css_list: [],
required_js_list: [],
};
if (html.constructor === String) {
// https://developer.mozilla.org/en-US/docs/HTML_in_XMLHttpRequest
// https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
// https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM
// parsed_xml = $($.parseXML(html));
// parsed_xml = $('<div/>').html(html);
parsed_xml = $((new DOMParser()).parseFromString(html, "text/html"));
settings.title = parsed_xml.find('head > title').first().text();
// XXX Manage relative URL during extraction of URLs
$.each(parsed_xml.find('head > link[rel=stylesheet]'),
function (i, link) {
settings.required_css_list.push($(link).attr('href'));
});
$.each(parsed_xml.find('head > script[type="text/javascript"]'),
function (i, script) {
settings.required_js_list.push($(script).attr('src'));
});
$.each(parsed_xml.find(
'head > link[rel="http://www.renderjs.org/rel/interface"]'
), function (i, link) {
settings.interface_list.push($(link).attr('href'));
});
settings.html = parsed_xml.find('html > body').first().html();
if (settings.html === undefined) {
settings.html = "";
}
result = settings;
} else {
throw new Error(html + " is not a string");
}
return result;
};
window.rJS = window.renderJS = renderJS;
window.RenderJSGadget = RenderJSGadget;
///////////////////////////////////////////////////
// Bootstrap process. Register the self gadget.
///////////////////////////////////////////////////
function bootstrap() {
var url = window.location.href,
tmp_constructor,
root_gadget,
loading_gadget_deferred = $.Deferred();
// Create the gadget class for the current url
if (gadget_model_dict.hasOwnProperty(url)) {
throw new Error("bootstrap should not be called twice");
}
// XXX Copy/Paste from declareGadgetKlass
tmp_constructor = function () {
RenderJSGadget.call(this);
};
tmp_constructor.declareMethod = RenderJSGadget.declareMethod;
tmp_constructor.ready_list = [];
tmp_constructor.ready = RenderJSGadget.ready;
tmp_constructor.prototype = new RenderJSGadget();
tmp_constructor.prototype.constructor = tmp_constructor;
tmp_constructor.prototype.path = url;
gadget_model_dict[url] = tmp_constructor;
// Create the root gadget instance and put it in the loading stack
root_gadget = new gadget_model_dict[url]();
gadget_loading_klass = tmp_constructor;
loading_gadget_promise = loading_gadget_deferred.promise();
$(document).ready(function () {
// XXX HTML properties can only be set when the DOM is fully loaded
var settings = renderJS.parseGadgetHTML($('html')[0].outerHTML),
promise,
key;
for (key in settings) {
if (settings.hasOwnProperty(key)) {
tmp_constructor.prototype[key] = settings[key];
}
}
root_gadget.context = $('body');
promise = $.when(root_gadget.getRequiredJSList(),
root_gadget.getRequiredCSSList())
.done(function (js_list, css_list) {
$.each(js_list, function (i, required_url) {
javascript_registration_dict[required_url] = null;
});
$.each(css_list, function (i, required_url) {
stylesheet_registration_dict[url] = null;
});
$.each(tmp_constructor.ready_list, function (i, callback) {
callback.apply(root_gadget);
});
gadget_loading_klass = undefined;
loading_gadget_deferred.resolve();
});
});
}
bootstrap();
}(document, window, jQuery, DOMParser));
///**
//* By default RenderJs will render all gadgets when page is loaded
//* still it's possible to override this and use explicit gadget rendering.
//*
//* @property RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING
//* @type {Boolean}
//* @default "true"
//*/
//var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING = true;
//
//
///**
//* By default RenderJs will examine and bind all interaction gadgets
//* available.
//*
//* @property RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND
//* @type {Boolean}
//* @default "true"
//*/
//var RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND = true;
//
///**
//* By default RenderJs will examine and create all routes
//*
//* @property RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE
//* @type {Boolean}
//* @default "true"
//*/
//var RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE = true;
//
///**
//Provides the base RenderJs class
//
//@module RenderJs
//**/
//var RenderJs = (function () {
// // a variable indicating if current gadget loading is over or not
// var is_ready = false, current_gadget;
//
// function setSelfGadget(gadget) {
// /*
// * Only used internally to set current gadget being executed.
// */
// current_gadget = gadget;
// }
//
// return {
//
// init: function () {
// /*
// * Do all initialization
// */
// if (RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING) {
// RenderJs.bootstrap($('body'));
// }
// var root_gadget = RenderJs.GadgetIndex.getRootGadget();
// if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND ||
// RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE) {
// // We might have a page without gadgets.
// // Be careful, right now we can be in this case because
// // asynchronous gadget loading is not finished
// if (root_gadget !== undefined) {
// RenderJs.bindReady(
// function () {
// if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND) {
// // examine all Intaction Gadgets and bind accordingly
// RenderJs.InteractionGadget.init();
// }
// if (RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE) {
// // create all routes between gadgets
// RenderJs.RouteGadget.init();
// }
// }
// );
// }
// }
// },
//
// bootstrap: function (root) {
// /*
// * Load all gadgets for this DOM element
// * (including recursively contained ones)
// */
// var gadget_id, is_gadget;
// gadget_id = root.attr("id");
// is_gadget = root.attr("data-gadget") !== undefined;
// // this will make RenderJs fire "ready" event when all
// // gadgets are loaded.
// RenderJs.setReady(false);
// if (is_gadget && gadget_id !== undefined) {
// // bootstart root gadget only if it is indeed a gadget
// RenderJs.loadGadget(root);
// }
// RenderJs.loadRecursiveGadget(root);
// },
//
// loadRecursiveGadget: function (root) {
// /*
// * Load all contained gadgets inside passed DOM element.
// */
// var gadget_list, gadget, gadget_id, gadget_js;
// gadget_list = root.find("[data-gadget]");
//
// // register all gadget in advance so checkAndTriggerReady
// // can have accurate information for list of all gadgets
// gadget_list.each(function () {
// gadget = $(this);
// gadget_id = gadget.attr("id");
// gadget_js = new RenderJs.Gadget(gadget_id, gadget);
// RenderJs.GadgetIndex.registerGadget(gadget_js);
// });
//
// // Load chilren
// gadget_list.each(function () {
// RenderJs.loadGadget($(this));
// });
// },
//
// setGadgetAndRecurse: function (gadget, data) {
// /*
// * Set gadget data and recursively load it in case it holds another
// * gadgets.
// */
// // set current gadget as being loaded so gadget instance itself
// // knows which gadget it is
// setSelfGadget(RenderJs.GadgetIndex.getGadgetById(gadget.attr("id")));
// gadget.append(data);
// // reset as no longer current gadget
// setSelfGadget(undefined);
// // a gadget may contain sub gadgets
// RenderJs.loadRecursiveGadget(gadget);
// },
//
// getSelfGadget: function () {
// /*
// * Get current gadget being loaded
// * This function must be used with care as it relies on
// * Javascript nature of being a single threaded application.
// * Currently current gadget is set in a global RenderJs variable
// * before its HTML is inserted into DOM and if multiple threads
// * were running (which is not the case currently)
// * this could lead to reace conditions and unreliable getSelfGadget
// * results.
// * Additionally this function is available only at gadget's script
// * load time - i.e. it can't be used in after that calls.
// * In this case gagdget can save this value internally.
// */
// return current_gadget;
// },
//
// loadGadget: function (gadget) {
// /*
// * Load gadget's SPECs from URL
// */
// var url, gadget_id, gadget_property, cacheable, cache_id,
// i, gadget_index, gadget_index_id,
// app_cache, data, gadget_js, is_update_gadget_data_running;
//
// url = gadget.attr("data-gadget");
// gadget_id = gadget.attr("id");
// gadget_js = RenderJs.GadgetIndex.getGadgetById(gadget_id);
// gadget_index = RenderJs.GadgetIndex.getGadgetList();
//
// if (gadget_js === undefined) {
// // register gadget in javascript namespace
// //if not already registered
// gadget_js = new RenderJs.Gadget(gadget_id, gadget);
// RenderJs.GadgetIndex.registerGadget(gadget_js);
// }
// if (gadget_js.isReady()) {
// // avoid loading again gadget which was loaded before in same page
// return;
// }
//
// // update Gadget's instance with contents of "data-gadget-property"
// gadget_property = gadget.attr("data-gadget-property");
// if (gadget_property !== undefined) {
// gadget_property = $.parseJSON(gadget_property);
// $.each(gadget_property, function (key, value) {
// gadget_js[key] = value;
// });
// }
//
// if (url !== undefined && url !== "") {
// cacheable = gadget.attr("data-gadget-cacheable");
// cache_id = gadget.attr("data-gadget-cache-id");
// if (cacheable !== undefined && cache_id !== undefined) {
// cacheable = Boolean(parseInt(cacheable, 10));
// }
// //cacheable = false ; // to develop faster
// if (cacheable) {
// // get from cache if possible, use last part from URL as
// // cache_key
// app_cache = RenderJs.Cache.get(cache_id, undefined);
// if (app_cache === undefined || app_cache === null) {
// // not in cache so we pull from network and cache
// $.ajax({
// url: url,
// yourCustomData: {
// "gadget_id": gadget_id,
// "cache_id": cache_id
// },
// success: function (data) {
// cache_id = this.yourCustomData.cache_id;
// gadget_id = this.yourCustomData.gadget_id;
// RenderJs.Cache.set(cache_id, data);
// RenderJs.GadgetIndex.getGadgetById(gadget_id).
// setReady();
// RenderJs.setGadgetAndRecurse(gadget, data);
// RenderJs.checkAndTriggerReady();
// RenderJs.updateGadgetData(gadget);
// }
// });
// } else {
// // get from cache
// data = app_cache;
// gadget_js.setReady();
// this.setGadgetAndRecurse(gadget, data);
// this.checkAndTriggerReady();
// RenderJs.updateGadgetData(gadget);
// }
// } else {
// // not to be cached
// $.ajax({
// url: url,
// yourCustomData: {"gadget_id": gadget_id},
// success: function (data) {
// gadget_id = this.yourCustomData.gadget_id;
// RenderJs.GadgetIndex.getGadgetById(gadget_id).
// setReady();
// RenderJs.setGadgetAndRecurse(gadget, data);
// RenderJs.checkAndTriggerReady();
// RenderJs.updateGadgetData(gadget);
// }
// });
// }
// } else {
// // gadget is an inline (InteractorGadget or one using
// // data-gadget-source / data-gadget-handler) so no need
// // to load it from network
// is_update_gadget_data_running = RenderJs.updateGadgetData(gadget);
// if (!is_update_gadget_data_running) {
// // no update is running so gadget is basically ready
// // if update is running then it should take care and set status
// gadget_js.setReady();
// }
// RenderJs.checkAndTriggerReady();
// }
// },
//
// isReady: function () {
// /*
// * Get rendering status
// */
// return is_ready;
// },
//
// setReady: function (value) {
// /*
// * Update rendering status
// */
// is_ready = value;
// },
//
// bindReady: function (ready_function) {
// /*
// * Bind a function on ready gadget loading.
// */
// $("body").one("ready", ready_function);
// },
//
// checkAndTriggerReady: function () {
// /*
// * Trigger "ready" event only if all gadgets were marked as "ready"
// */
// var is_gadget_list_loaded;
// is_gadget_list_loaded = RenderJs.GadgetIndex.isGadgetListLoaded();
// if (is_gadget_list_loaded) {
// if (!RenderJs.isReady()) {
// // backwards compatability with already written code
// RenderJs.GadgetIndex.getRootGadget().getDom().
// trigger("ready");
// // trigger ready on root body element
// $("body").trigger("ready");
// // this set will make sure we fire this event only once
// RenderJs.setReady(true);
// }
// }
// return is_gadget_list_loaded;
// },
//
// updateGadgetData: function (gadget) {
// /*
// * Gadget can be updated from "data-gadget-source" (i.e. a json)
// * and "data-gadget-handler" attributes (i.e. a namespace Javascript)
// */
// var data_source, data_handler;
// data_source = gadget.attr("data-gadget-source");
// data_handler = gadget.attr("data-gadget-handler");
// // acquire data and pass it to method handler
// if (data_source !== undefined && data_source !== "") {
// $.ajax({
// url: data_source,
// dataType: "json",
// yourCustomData: {"data_handler": data_handler,
// "gadget_id": gadget.attr("id")},
// success: function (result) {
// var data_handler, gadget_id;
// data_handler = this.yourCustomData.data_handler;
// gadget_id = this.yourCustomData.gadget_id;
// if (data_handler !== undefined) {
// // eval is not nice to use
// eval(data_handler + "(result)");
// gadget = RenderJs.GadgetIndex.getGadgetById(gadget_id);
// // mark gadget as loaded and fire a check
// // to see if all gadgets are loaded
// gadget.setReady();
// RenderJs.checkAndTriggerReady();
// }
// }
// });
// // asynchronous update happens and respective thread will update
// // status
// return true;
// }
// return false;
// },
//
// addGadget: function (dom_id, gadget_id, gadget, gadget_data_handler,
// gadget_data_source, bootstrap) {
// /*
// * add new gadget and render it
// */
// var html_string, tab_container, tab_gadget;
// tab_container = $('#' + dom_id);
// tab_container.empty();
// html_string = [
// '<div id="' + gadget_id + '"',
// 'data-gadget="' + gadget + '"',
// 'data-gadget-handler="' + gadget_data_handler + '" ',
// 'data-gadget-source="' + gadget_data_source + '"></div>'
// ].join('\n');
//
// tab_container.append(html_string);
// tab_gadget = tab_container.find('#' + gadget_id);
//
// // render new gadget
// if (bootstrap !== false) {
// RenderJs.bootstrap(tab_container);
// }
//
// return tab_gadget;
// },
//
// Cache: (function () {
// /*
// * Generic cache implementation that can fall back to local
// * namespace storage if no "modern" storage like localStorage
// * is available
// */
// return {
// ROOT_CACHE_ID: 'APP_CACHE',
//
// getCacheId: function (cache_id) {
// /*
// * We should have a way to 'purge' localStorage by setting a
// * ROOT_CACHE_ID in all browser instances
// */
// return this.ROOT_CACHE_ID + cache_id;
// },
//
// hasLocalStorage: function () {
// /*
// * Feature test if localStorage is supported
// */
// var mod;
// mod = 'localstorage_test_12345678';
// try {
// localStorage.setItem(mod, mod);
// localStorage.removeItem(mod);
// return true;
// } catch (e) {
// return false;
// }
// },
//
// get: function (cache_id, default_value) {
// /* Get cache key value */
// cache_id = this.getCacheId(cache_id);
// if (this.hasLocalStorage()) {
// return this.LocalStorageCachePlugin.
// get(cache_id, default_value);
// }
// //fallback to javscript namespace cache
// return this.NameSpaceStorageCachePlugin.
// get(cache_id, default_value);
// },
//
// set: function (cache_id, data) {
// /* Set cache key value */
// cache_id = this.getCacheId(cache_id);
// if (this.hasLocalStorage()) {
// this.LocalStorageCachePlugin.set(cache_id, data);
// } else {
// this.NameSpaceStorageCachePlugin.set(cache_id, data);
// }
// },
//
// LocalStorageCachePlugin: (function () {
// /*
// * This plugin saves using HTML5 localStorage.
// */
// return {
// get: function (cache_id, default_value) {
// /* Get cache key value */
// if (localStorage.getItem(cache_id) !== null) {
// return JSON.parse(localStorage.getItem(cache_id));
// }
// return default_value;
// },
//
// set: function (cache_id, data) {
// /* Set cache key value */
// localStorage.setItem(cache_id, JSON.stringify(data));
// }
// };
// }()),
//
// NameSpaceStorageCachePlugin: (function () {
// /*
// * This plugin saves within current page namespace.
// */
// var namespace = {};
//
// return {
// get: function (cache_id, default_value) {
// /* Get cache key value */
// return namespace[cache_id];
// },
//
// set: function (cache_id, data) {
// /* Set cache key value */
// namespace[cache_id] = data;
// }
// };
// }())
// };
// }()),
//
// Gadget: function (gadget_id, dom) {
// /*
// * Javascript Gadget representation
// */
// this.id = gadget_id;
// this.dom = dom;
// this.is_ready = false;
// },
//
// TabbularGadget: (function () {
// /*
// * Generic tabular gadget
// */
// var gadget_list = [];
// return {
// toggleVisibility: function (visible_dom) {
// /*
// * Set tab as active visually and mark as not active rest.
// */
// $(".selected").addClass("not_selected");
// $(".selected").removeClass("selected");
// visible_dom.addClass("selected");
// visible_dom.removeClass("not_selected");
// },
//
// addNewTabGadget: function (dom_id, gadget_id, gadget,
// gadget_data_handler,
// gadget_data_source, bootstrap) {
// /*
// * add new gadget and render it
// */
// var tab_gadget;
// tab_gadget = RenderJs.addGadget(
// dom_id,
// gadget_id,
// gadget,
// gadget_data_handler,
// gadget_data_source,
// bootstrap
// );
//
// // we should unregister all gadgets part of this TabbularGadget
// $.each(gadget_list,
// function (index, gadget_id) {
// var gadget = RenderJs.GadgetIndex.getGadgetById(gadget_id);
// gadget.remove();
// // update list of root gadgets inside TabbularGadget
// gadget_list.splice($.inArray(gadget_id, gadget_list), 1);
// }
// );
// // add it as root gadget
// gadget_list.push(tab_gadget.attr("id"));
// }
// };
// }()),
//
// GadgetIndex: (function () {
// /*
// * Generic gadget index placeholder
// */
// var gadget_list = [];
//
// return {
//
// getGadgetIdListFromDom: function (dom) {
// /*
// * Get list of all gadget's ID from DOM
// */
// var gadget_id_list = [];
// $.each(dom.find('[data-gadget]'),
// function (index, value) {
// gadget_id_list.push($(value).attr("id"));
// }
// );
// return gadget_id_list;
// },
//
// setGadgetList: function (gadget_list_value) {
// /*
// * Set list of registered gadgets
// */
// gadget_list = gadget_list_value;
// },
//
// getGadgetList: function () {
// /*
// * Return list of registered gadgets
// */
// return gadget_list;
// },
//
// registerGadget: function (gadget) {
// /*
// * Register gadget
// */
// if (RenderJs.GadgetIndex.getGadgetById(gadget.id) ===
// undefined) {
// // register only if not already added
// gadget_list.push(gadget);
// }
// },
//
// unregisterGadget: function (gadget) {
// /*
// * Unregister gadget
// */
// var index = $.inArray(gadget, gadget_list);
// if (index !== -1) {
// gadget_list.splice(index, 1);
// }
// },
//
// getGadgetById: function (gadget_id) {
// /*
// * Get gadget javascript representation by its Id
// */
// var gadget;
// gadget = undefined;
// $(RenderJs.GadgetIndex.getGadgetList()).each(
// function (index, value) {
// if (value.getId() === gadget_id) {
// gadget = value;
// }
// }
// );
// return gadget;
// },
//
// getRootGadget: function () {
// /*
// * Return root gadget (always first one in list)
// */
// return this.getGadgetList()[0];
// },
//
// isGadgetListLoaded: function () {
// /*
// * Return True if all gadgets were loaded from network or
// * cache
// */
// var result;
// result = true;
// $(this.getGadgetList()).each(
// function (index, value) {
// if (value.isReady() === false) {
// result = false;
// }
// }
// );
// return result;
// }
// };
// }()),
//
// GadgetCatalog : (function () {
// /*
// * Gadget catalog provides API to get
// * list of gadgets from a repository
// */
// var cache_id = "setGadgetIndexUrlList";
//
// function updateGadgetIndexFromURL(url) {
// // split to base and document url
// var url_list = url.split('/'),
// document_url = url_list[url_list.length - 1],
// d = url_list.splice($.inArray(document_url, url_list), 1),
// base_url = url_list.join('/'),
// web_dav = jIO.newJio({
// "type": "dav",
// "username": "",
// "password": "",
// "url": base_url
// });
// web_dav.get(document_url,
// function (err, response) {
// RenderJs.Cache.set(url, response);
// });
// }
//
// return {
// updateGadgetIndex: function () {
// /*
// * Update gadget index from all configured remote repositories.
// */
// $.each(RenderJs.GadgetCatalog.getGadgetIndexUrlList(),
// function (index, value) {
// updateGadgetIndexFromURL(value);
// });
// },
//
// setGadgetIndexUrlList: function (url_list) {
// /*
// * Set list of Gadget Index repositories.
// */
// // store in Cache (html5 storage)
// RenderJs.Cache.set(cache_id, url_list);
// },
//
// getGadgetIndexUrlList: function () {
// /*
// * Get list of Gadget Index repositories.
// */
// // get from Cache (html5 storage)
// return RenderJs.Cache.get(cache_id, undefined);
// },
//
// getGadgetListThatProvide: function (service) {
// /*
// * Return list of all gadgets that providen a given service.
// * Read this list from data structure created in HTML5 local
// * storage by updateGadgetIndexFromURL
// */
// // get from Cache stored index and itterate over it
// // to find matching ones
// var gadget_list = [];
// $.each(RenderJs.GadgetCatalog.getGadgetIndexUrlList(),
// function (index, url) {
// // get repos from cache
// var cached_repo = RenderJs.Cache.get(url);
// $.each(cached_repo.gadget_list,
// function (index, gadget) {
// if ($.inArray(service, gadget.service_list) > -1) {
// // gadget provides a service, add to list
// gadget_list.push(gadget);
// }
// }
// );
// });
// return gadget_list;
// },
//
// registerServiceList: function (gadget, service_list) {
// /*
// * Register a service provided by a gadget.
// */
// }
// };
// }()),
//
// InteractionGadget : (function () {
// /*
// * Basic gadget interaction gadget implementation.
// */
// return {
//
// init: function (force) {
// /*
// * Inspect DOM and initialize this gadget
// */
// var dom_list, gadget_id;
// if (force === 1) {
// // we explicitly want to re-init elements even if already this
// // is done before
// dom_list = $("div[data-gadget-connection]");
// } else {
// // XXX: improve and save 'bound' on javascript representation
// // of a gadget not DOM
// dom_list = $("div[data-gadget-connection]")
// .filter(function () {
// return $(this).data("bound") !== true;
// })
// .data('bound', true);
// }
// dom_list.each(function (index, element) {
// RenderJs.InteractionGadget.bind($(element));
// });
// },
//
// bind: function (gadget_dom) {
// /*
// * Bind event between gadgets.
// */
// var gadget_id, gadget_connection_list,
// createMethodInteraction = function (
// original_source_method_id,
// source_gadget_id,
// source_method_id,
// destination_gadget_id,
// destination_method_id
// ) {
// var interaction = function () {
// // execute source method
// RenderJs.GadgetIndex.getGadgetById(
// source_gadget_id
// )[original_source_method_id].
// apply(null, arguments);
// // call trigger so bind can be asynchronously called
// RenderJs.GadgetIndex.getGadgetById(
// destination_gadget_id
// ).dom.trigger(source_method_id);
// };
// return interaction;
// },
// createTriggerInteraction = function (
// destination_gadget_id,
// destination_method_id
// ) {
// var interaction = function () {
// RenderJs.GadgetIndex.getGadgetById(
// destination_gadget_id
// )[destination_method_id].
// apply(null, arguments);
// };
// return interaction;
// };
// gadget_id = gadget_dom.attr("id");
// gadget_connection_list =
// gadget_dom.attr("data-gadget-connection");
// gadget_connection_list = $.parseJSON(gadget_connection_list);
// $.each(gadget_connection_list, function (key, value) {
// var source,
// source_gadget_id,
// source_method_id,
// source_gadget,
// destination,
// destination_gadget_id,
// destination_method_id,
// destination_gadget,
// original_source_method_id;
// source = value.source.split(".");
// source_gadget_id = source[0];
// source_method_id = source[1];
// source_gadget = RenderJs.GadgetIndex.
// getGadgetById(source_gadget_id);
//
// destination = value.destination.split(".");
// destination_gadget_id = destination[0];
// destination_method_id = destination[1];
// destination_gadget = RenderJs.GadgetIndex.
// getGadgetById(destination_gadget_id);
//
// if (source_gadget.hasOwnProperty(source_method_id)) {
// // direct javascript use case
// original_source_method_id = "original_" +
// source_method_id;
// source_gadget[original_source_method_id] =
// source_gadget[source_method_id];
// source_gadget[source_method_id] =
// createMethodInteraction(
// original_source_method_id,
// source_gadget_id,
// source_method_id,
// destination_gadget_id,
// destination_method_id
// );
// // we use html custom events for asyncronous method call so
// // bind destination_gadget to respective event
// destination_gadget.dom.bind(
// source_method_id,
// createTriggerInteraction(
// destination_gadget_id,
// destination_method_id
// )
// );
// } else {
// // this is a custom event attached to HTML gadget
// // representation
// source_gadget.dom.bind(
// source_method_id,
// createTriggerInteraction(
// destination_gadget_id,
// destination_method_id
// )
// );
// }
// });
// }
// };
// }()),
//
// RouteGadget : (function () {
// /*
// * A gadget that defines possible routes (i.e. URL changes)
// * between gadgets.
// */
// var route_list = [];
// return {
//
// init: function () {
// /*
// * Inspect DOM and initialize this gadget
// */
// $("div[data-gadget-route]").each(function (index, element) {
// RenderJs.RouteGadget.route($(element));
// });
// },
//
// route: function (gadget_dom) {
// /*
// * Create routes between gadgets.
// */
// var body = $("body"),
// handler_func,
// priority,
// gadget_route_list = gadget_dom.attr("data-gadget-route");
// gadget_route_list = $.parseJSON(gadget_route_list);
// $.each(gadget_route_list, function (key, gadget_route) {
// handler_func = function () {
// var gadget_id = gadget_route.destination.split('.')[0],
// method_id = gadget_route.destination.split('.')[1],
// gadget = RenderJs.GadgetIndex.getGadgetById(gadget_id);
// // set gadget value so getSelfGadget can work
// setSelfGadget(gadget);
// gadget[method_id].apply(null, arguments);
// // reset as no longer needed
// setSelfGadget(undefined);
// };
// // add route itself
// priority = gadget_route.priority;
// if (priority === undefined) {
// // default is 1 -i.e.first level
// priority = 1;
// }
// RenderJs.RouteGadget.add(gadget_route.source,
// handler_func, priority);
// });
// },
//
// add: function (path, handler_func, priority) {
// /*
// * Add a route between path (hashable) and a handler function
// * (part of Gadget's API).
// */
// var body = $("body");
// body
// .route("add", path, 1)
// .done(handler_func);
// // save locally
// route_list.push({"path": path,
// "handler_func": handler_func,
// "priority": priority});
// },
//
// go: function (path, handler_func, priority) {
// /*
// * Go a route.
// */
// var body = $("body");
// body
// .route("go", path, priority)
// .fail(handler_func);
// },
//
// remove: function (path) {
// /*
// * Remove a route.
// */
//
// // XXX: implement remove a route when route.js supports it
// },
//
// getRouteList: function () {
// /*
// * Get list of all router
// */
// return route_list;
// }
// };
// }())
// };
// }());
//
//// Define Gadget prototype
//RenderJs.Gadget.prototype.getId = function () {
// return this.id;
//};
//
//RenderJs.Gadget.prototype.getDom = function () {
// return this.dom;
//};
//
//RenderJs.Gadget.prototype.isReady = function () {
// /*
// * Return True if remote gadget is loaded into DOM.
// */
// return this.is_ready;
//};
//
//RenderJs.Gadget.prototype.setReady = function () {
// /*
// * Return True if remote gadget is loaded into DOM.
// */
// this.is_ready = true;
//};
//
//RenderJs.Gadget.prototype.remove = function () {
// /*
// * Remove gadget (including its DOM element).
// */
// var gadget;
// // unregister root from GadgetIndex
// RenderJs.GadgetIndex.unregisterGadget(this);
// // gadget might contain sub gadgets so before remove entire
// // DOM we must unregister them from GadgetIndex
// this.getDom().find("[data-gadget]").each(function () {
// gadget = RenderJs.GadgetIndex.getGadgetById($(this).attr("id"));
// RenderJs.GadgetIndex.unregisterGadget(gadget);
// });
// // remove root's entire DOM element
// $(this.getDom()).remove();
//};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment