Browse files

mass与avalon正式分家

  • Loading branch information...
1 parent 84cf6f2 commit a9aa375e497852c091607e921a59592207fefff6 @RubyLouvre committed Jun 9, 2013
Showing with 0 additions and 15,932 deletions.
  1. +0 −47 avalon.accordion.js
  2. +0 −125 avalon.autocomplete.js
  3. +0 −151 avalon.button.js
  4. +0 −264 avalon.colorpicker.js
  5. +0 −14 avalon.dialog.html
  6. +0 −184 avalon.dialog.js
  7. +0 −314 avalon.draggable.js
  8. +0 −2,439 avalon.js
  9. +0 −123 avalon.pagination.js
  10. +0 −35 avalon.progressbar.js
  11. +0 −379 avalon.router.js
  12. +0 −23 avalon.select.css
  13. +0 −173 avalon.select.js
  14. +0 −154 avalon.slider.js
  15. +0 −62 avalon.spinner.js
  16. +0 −92 avalon.switch.js
  17. +0 −75 avalon.sync.js
  18. +0 −81 avalon.tabs.js
  19. +0 −2,488 avalon20130521.js
  20. +0 −2,431 avalon20130522.js
  21. +0 −2,439 avalon20130523.js
  22. +0 −2,437 avalon20130524.js
  23. +0 −60 avalon_min.js
  24. +0 −50 index.html
  25. +0 −47 index10.html
  26. +0 −38 index11.html
  27. +0 −230 index13.html
  28. +0 −102 index2.html
  29. +0 −126 index3.html
  30. +0 −212 index4.html
  31. +0 −65 index5.html
  32. +0 −258 index6.html
  33. +0 −117 index8.html
  34. +0 −97 index9.html
View
47 avalon.accordion.js
@@ -1,47 +0,0 @@
-(function(avalon) {
- var defaults = {
- active: 0
- };
- avalon.ui.accordion = function(element, id) {
- var $element = avalon(element),
- model, el
- var fragment = document.createDocumentFragment();
- //处理配置
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- $element.addClass(" ui-accordion ui-widget ui-helper-reset");
- var el, tabs = [],
- tabpanels = [];
-
- while (el = element.firstChild) {
- fragment.appendChild(el);
- if (el.tagName === "H3") {
- el.setAttribute("ms-hover", "ui-state-hover");
- el.setAttribute("ms-click", "activate");
- avalon(el).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-accordion-icons ui-corner-all");
- var icon = document.createElement("span");
- icon.className = "ui-accordion-header-icon ui-icon ui-icon-triangle-1-e";
- icon.setAttribute("ms-class-ui-icon-triangle-1-s", "active == " + tabs.length);
- icon.setAttribute("ms-class-ui-icon-triangle-1-e", "active != " + tabs.length);
- el.appendChild(icon);
- tabs.push(el);
- }
- if (el.tagName === "DIV") {
- el.setAttribute("ms-visible", "active == " + tabpanels.length);
- tabpanels.push(el);
- avalon(el).addClass(" ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");
- }
- }
- var model = avalon.define(id, function(vm) {
- vm.active = options.active;
- vm.activate = function(e) {
- e.preventDefault();
- vm.active = tabs.indexOf(this);
- };
- });
- avalon.nextTick(function() {
- element.appendChild(fragment);
- avalon.scan(element, model);
- });
- }
-})(this.avalon)
View
125 avalon.autocomplete.js
@@ -1,125 +0,0 @@
-(function(avalon) {
- var defaults = {
- items: 8
- };
- var preventOne = avalon.oneObject("9,13,27,40,38");
-
- avalon.ui.autocomplete = function(element, id, opts) {
- var $element = avalon(element),
- refreshList,
- tempValue = "",
- model;
- //处理配置
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- var source = Array.isArray(opts) ? opts.sort() : [];
- var sourceList = document.createElement("div");
- sourceList.innerHTML = '<ul ms-important="' + id + '" class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all" ms-each-presentation="matcher" ms-visible="show" >' +
- '<li class="ui-menu-item" ><a class="ui-corner-all" tabindex="-1" ms-mouseover="get" ms-hover="ui-state-focus" ms-class-ui-state-focus="matcher[selectedIndex] === presentation " >{{presentation}}</a></li>' +
- '</ul>';
-
- sourceList = sourceList.firstChild;
- $element.bind("blur", function() {
- setTimeout(function() {
- refreshList = model.show = false; //隐藏datalist
- }, 250);
- });
- avalon.bind(sourceList, "click", function() {
- model.value = model.overvalue;
- })
- $element.bind("keyup", function(e) {
- if (/\w/.test(String.fromCharCode(e.which))) { //如果是字母数字键
- refreshList = true; //这是方便在datalist显示时,动态刷新datalist
- model.value = element.value; //触发$watch value回调
- } else {
- refreshList = false
- switch (e.which) {
- case 8:
- refreshList = true;//回退键可以引发列表刷新
- break;
- case 13:
- tempValue = model.value;
- refreshList = model.show = false;
- break;
- case 38:
- // up arrow
- --model.selectedIndex;
- if (model.selectedIndex === -2) {
- model.selectedIndex = model.matcher.length - 1;
- }
- var value = model.matcher[model.selectedIndex];
- model.value = value === void 0 ? tempValue : value;
- break
-
- case 40:
- // down arrow
- ++model.selectedIndex;
- if (model.selectedIndex === model.matcher.length) {
- model.selectedIndex = -1;
- }
- var value = model.matcher[model.selectedIndex];
- model.value = value === void 0 ? tempValue : value;
- break;
- }
- }
-
- });
-
- model = avalon.define(id, function(vm) {
- vm.show = false;
- vm.selectedIndex = -1;
- vm.value = element.value;
- vm.matcher = [];
- vm.overvalue = "";
- vm.get = function() {
- vm.overvalue = this.$scope.presentation
- }
- vm.$watch("value", function(value) {
- if (refreshList !== false) { //flagKeyup是控制datalist的刷新
- model.show = true;
- tempValue = value;
- var lower = [];
- var matcher = source.filter(function(el) {
- if (el.indexOf(value) === 0) {
- return el; //最精确
- }
- if (el.toLowerCase().indexOf(value.toLowerCase()) === 0) {
- lower.push(el); //不区分大小写
- }
- });
- lower = matcher.concat(lower);
- var query = value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
- var strongRegExp = new RegExp('(' + query + ')', 'ig');
- if (lower.length) {
- vm.matcher = lower.slice(0, options.items);
- } else { //模糊匹配,只要它中间有这些字母就行
- vm.matcher = source.filter(function(el) {
- return strongRegExp.test(el);
- });
- }
- }
- });
- });
- avalon.ready(function() {
- element.setAttribute("ms-model", "value");
- document.body.appendChild(sourceList);
- adjustPosition();
- avalon.scan(element, model);
- avalon.scan(sourceList, model);
- });
-
- function adjustPosition() {
- var offset = $element.offset();
- sourceList.style.width = element.clientWidth + "px";
- sourceList.style.left = offset.left + "px";
- sourceList.style.top = offset.top + element.offsetHeight + "px";
- sourceList.style.zIndex = 9999;
- if (avalon(document).height() - 200 > offset.top) {
- var pageY = sourceList.offsetHeight + parseFloat(sourceList.style.top);
- window.scrollTo(pageY + 50, 0);
- }
- }
- $element.bind("focus", adjustPosition);
-
- };
-})(window.avalon);
View
151 avalon.button.js
@@ -1,151 +0,0 @@
-(function(avalon) {
- var defaults = {
- disabled: false
- };
- avalon.ui.button = function(element, id) {
-
- var $element = avalon(element),
- model, el, checkbox;
- var title = element.title,
- html = element.innerHTML;
- var fragment = document.createDocumentFragment();
- element.title = "";
- //处理配置
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- //处理radio, checkbox
- var isRadio = element.type === "radio";
- var isCheckbox = element.type === "checkbox";
- var radios = [];
- if (isRadio && element.parentNode.$radio) {
- model = element.parentNode.$radio;
- radios = model.$radios;
- }
- var radioIndex = radios.length;
- var toggleButton = isCheckbox || isRadio;
- var activeClass = !toggleButton ? "ui-state-active" : "";
- if (toggleButton) { //偷天换日,用label代替原来的input[type=checkbox],input[type=checkbox]
- var label = document.createElement("label");
- checkbox = element;
- label.innerHTML = options.label || checkbox.value;
- checkbox.parentNode.insertBefore(label, checkbox.nextSibling);
- $element.addClass("ui-helper-hidden-accessible");
- element = label;
- $element = avalon(element);
- }
- while (el = element.firstChild) {
- fragment.appendChild(el);
- }
- $element.addClass("ui-button ui-widget ui-state-default");
-
- element.title = title;
-
- //如果使用了buttonset
- if (!options.cornerClass) {
- $element.addClass("ui-corner-all");
- }
- if (typeof options.cornerClass === "string") {
- $element.addClass(options.cornerClass);
- }
-
- //创建按钮的内部,将它原来的内部放到一个span.ui-button-text
- if (fragment.childNodes.length) {
- var span = document.createElement("span");
- span.className = "ui-button-text";
- while (fragment.firstChild) {
- span.appendChild(fragment.firstChild);
- }
- $element.addClass("ui-button-text-only");
- fragment.appendChild(span);
- }
- //如果指定了icon, icon也占用一个span
- var iconClass = options.text === false ? "ui-button-icon-only" : typeof options.secondary === "string" ? "ui-button-text-icons" : typeof options.primary === "string" ? "ui-button-text-icon-primary" : ""
- if (options.text === false) {
- element.title = title || html;
- }
- if (iconClass) {
- $element.addClass(iconClass);
- }
- if (options.primary) {
- $element.removeClass("ui-button-text-only");
- var span = document.createElement("span");
- span.className = options.primary + " ui-button-icon-primary ui-icon";
- fragment.insertBefore(span, fragment.firstChild);
- }
- if (options.secondary) {
- $element.removeClass("ui-button-text-only");
- var span = document.createElement("span");
- span.className = options.secondary + " ui-button-icon-secondary ui-icon";
- fragment.appendChild(span);
- }
-
- $element.bind("mousedown", function(e) {
- if (model.disabled) {
- return false;
- }
- $element.addClass(activeClass);
- });
- $element.bind("mouseup", function(e) {
- if (model.disabled) {
- return false;
- }
- $element.removeClass(activeClass);
- });
- if (isCheckbox) {
- $element.bind("click", function() {
- model.checked = !model.checked
- });
- }
- if (isRadio) {
- $element.bind("click", function() {
- model.radioActived = radioIndex;
- });
- }
- if (!model) {
- model = avalon.define(id, function(vm) {
- vm.disabled = options.disabled;
- vm.radioActived = 0;
- vm.checked = !! (checkbox || {}).checked;
- vm.$radios = [];
- });
- }
- if (isRadio) {
- element.parentNode.$radio = model;
- model.$radios.push(element);
- }
- avalon.nextTick(function() {
- if (element.tagName !== "INPUT") {
- element.appendChild(fragment);
- }
- element.setAttribute("ms-hover", "ui-state-hover");
- element.setAttribute("ms-class-ui-state-disabled", "disabled");
- if (isCheckbox) {
- element.setAttribute("ms-class-ui-state-active", "checked");
- checkbox.setAttribute("ms-checked", "checked");
- }
- if (isRadio) {
- element.setAttribute("ms-class-ui-state-active", "radioActived == " + radioIndex);
- element.setAttribute("ms-checked", "radioActived == " + radioIndex);
- }
- if (toggleButton) {
- avalon.scan(checkbox, model);
- }
- avalon.scan(element, model);
- });
- return model
- };
-})(window.avalon);
-
-(function(avalon) {
- avalon.ui.buttonset = function(element, id) {
- var $element = avalon(element);
- $element.addClass("ui-buttonset");
- var children = element.children;
- for (var i = 0, el; el = children[i++];) {
- el.setAttribute("data-corner-class", "true");
- }
- children[0].setAttribute("data-corner-class", "ui-corner-left");
- children[children.length - 1].setAttribute("data-corner-class", "ui-corner-right");
- };
-})(window.avalon);
-//X-tag和Web组件帮你提速应用开发 http://mozilla.com.cn/post/51451/
View
264 avalon.colorpicker.js
@@ -1,264 +0,0 @@
-
-// http://www.knallgrau.at/code/colorpicker/demo
-(function(avalon) {
- var defaults = {
- imagesBase: "colorpicker/",
- toggle: false,
- top: 0,
- left: 0
- };
- var UI = avalon.ui["colorpicker"] = function(element, id) {
- var $element = avalon(element);
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- var domParser = document.createElement("div"), model;
- domParser.innerHTML = '<div ms-visible="toggle" ms-important="' + id + '" class="colorpicker ui-widget ui-widget-content ui-corner-all"><div class="colorpicker-div ui-corner-all" >' + (
- (typeof document.documentElement.style.maxHeight === 'undefined') ? // apply png fix for ie 5.5 and 6.0
- '<img class="colorpicker-bg" src="' + options.imagesBase + 'blank.gif" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + options.imagesBase + 'pickerbg.png\', sizingMethod=\'scale\')" alt="">' :
- '<img class="colorpicker-bg" src="' + options.imagesBase + 'pickerbg.png" alt="">'
- ) +
- '<div class="colorpicker-bg-overlay" style="z-index: 1002;"></div>' +
- '<div class="colorpicker-selector" ms-draggable="updateSelector" data-containment="parent" ms-css-left="selectorLeft" ms-css-top="selectorTop" ><img src="' + options.imagesBase + 'select.gif" width="11" height="11" alt="" /></div></div>' +
- '<div class="colorpicker-hue-container"><img src="' + options.imagesBase + 'hue.png" class="colorpicker-hue-bg-img"><div class="colorpicker-hue-slider">' +
- '<div class="colorpicker-hue-thumb" ms-css-top="hueValue" ms-draggable="updateHue" data-containment="parent" data-axis="y"><img src="' + options.imagesBase + 'hline.png"></div></div></div>' +
- '<div class="colorpicker-footer "><span class="colorpicker-value" ms-css-color="#{{hexValue}}">#{{hexValue}}</span>' +
- '<button class="colorpicker-okbutton" ms-click="closePicker" ms-ui="button" data-primary="ui-icon-close" data-text="false">OK</button></div></div>';
- var colorpicker = domParser.firstChild;
- var pickerArea = colorpicker.children[0];
- avalon.ready(function() {
- document.body.appendChild(colorpicker);
- avalon.scan(element, model);
- avalon.scan(colorpicker, model);
- $element.bind("click", function() {
- model.toggle = !model.toggle;
- model.pickerHeight = pickerArea.offsetHeight;
- model.pickerWidth = pickerArea.offsetWidth;
- if (model.toggle) {
- var offset = $element.offset();
- var left = offset.left + element.offsetWidth + 10;
- colorpicker.style.left = left + "px";
- colorpicker.style.top = offset.top + "px";
- }
- });
- });
-
- model = avalon.define(id, function(vm) {
- vm.toggle = options.toggle;
-
- vm.selectorLeft = 0;
- vm.selectorTop = 0;
-
- vm.pickerHeight = 0;
- vm.pickerWidth = 0;
- vm.hueValue = 0;
- // vm.hexColor = "000"
- vm.hexValue = element.value;
- vm.$hsv = {};
- vm.$rgb = {};
- vm.closePicker = function() {
- vm.toggle = false;
- };
- vm.updateSelector = function(event, data) {
- options.left = data.left;
- options.top = data.top;
- this.style.top = data.top + 6 + "px";
- this.style.left = data.left + 6 + "px";
- vm.update(data.left, data.top);
- };
- vm.updateHue = function(event, data) {
- var v = data.top;
- vm.hueValue = v;
- var h = (vm.pickerHeight - v) / vm.pickerHeight;
- if (h === 1)
- h = 0;
- var rgb = UI.Color.hsv2rgb(h, 1, 1);
- if (!UI.Color.isValidRGB(rgb))
- return;
- pickerArea.style.backgroundColor = "rgb(" + rgb + ")";
- vm.update();
- };
- vm.update = function(x, y) {
- if (!arguments.length) {
- x = options.left;
- y = options.top;
- }
- var h = (vm.pickerHeight - vm.hueValue) / vm.pickerHeight;
- if (h === 1) {
- h = 0;
- }
- vm.$hsv = {
- hue: 1 - vm.hueValue / 100,
- saturation: x / vm.pickerWidth,
- brightness: (vm.pickerHeight - y) / vm.pickerHeight
- };
- var rgb = UI.Color.hsv2rgb(vm.$hsv.hue, vm.$hsv.saturation, vm.$hsv.brightness);
- element.value = UI.Color.rgb2hex(rgb[0], rgb[1], rgb[2]);
- vm.hexValue = element.value;
- // vm.hexColor = vm.$hsv.brightness > 0.65 ? "000000" : "FFFFFF";
- };
- vm.updateFromFieldValue = function(e) {
- var input = e ? e.target : element;
- var rgb = UI.Color.hex2rgb(input.value);
- if (!UI.Color.isValidRGB(rgb))
- return;
- var hsv = UI.Color.rgb2hsv(rgb[0], rgb[1], rgb[2]);
- vm.selectorLeft = Math.round(hsv[1] * vm.pickerWidth);
- vm.selectorTop = Math.round((1 - hsv[2]) * vm.pickerWidth);
- vm.hueValue = vm.pickerHeight * (1 - hsv[0]);
- vm.update();
- }
- vm.$watch("toggle", function() {
- vm.updateFromFieldValue()
- });
- });
-
-
- };
-
-
- UI.Color = new function() {
-
- // Adapted from http://www.easyrgb.com/math.html
- // hsv values = 0 - 1
- // rgb values 0 - 255
- this.hsv2rgb = function(h, s, v) {
- var r, g, b;
- if (s == 0) {
- r = v * 255;
- g = v * 255;
- b = v * 255;
- } else {
-
- // h must be < 1
- var var_h = h * 6;
- if (var_h == 6) {
- var_h = 0;
- }
-
- //Or ... var_i = floor( var_h )
- var var_i = Math.floor(var_h);
- var var_1 = v * (1 - s);
- var var_2 = v * (1 - s * (var_h - var_i));
- var var_3 = v * (1 - s * (1 - (var_h - var_i)));
-
- if (var_i == 0) {
- var_r = v;
- var_g = var_3;
- var_b = var_1;
- } else if (var_i == 1) {
- var_r = var_2;
- var_g = v;
- var_b = var_1;
- } else if (var_i == 2) {
- var_r = var_1;
- var_g = v;
- var_b = var_3
- } else if (var_i == 3) {
- var_r = var_1;
- var_g = var_2;
- var_b = v;
- } else if (var_i == 4) {
- var_r = var_3;
- var_g = var_1;
- var_b = v;
- } else {
- var_r = v;
- var_g = var_1;
- var_b = var_2
- }
-
- r = var_r * 255 //rgb results = 0 � 255
- g = var_g * 255
- b = var_b * 255
-
- }
- return [Math.round(r), Math.round(g), Math.round(b)];
- };
-
- // added by Matthias Platzer AT knallgrau.at
- this.rgb2hsv = function(r, g, b) {
- var r = (r / 255); //RGB values = 0 � 255
- var g = (g / 255);
- var b = (b / 255);
-
- var min = Math.min(r, g, b); //Min. value of RGB
- var max = Math.max(r, g, b); //Max. value of RGB
- deltaMax = max - min; //Delta RGB value
-
- var v = max;
- var s, h;
- var deltaRed, deltaGreen, deltaBlue;
-
- if (deltaMax == 0) //This is a gray, no chroma...
- {
- h = 0; //HSV results = 0 � 1
- s = 0;
- }
- else //Chromatic data...
- {
- s = deltaMax / max;
-
- deltaRed = (((max - r) / 6) + (deltaMax / 2)) / deltaMax;
- deltaGreen = (((max - g) / 6) + (deltaMax / 2)) / deltaMax;
- deltaBlue = (((max - b) / 6) + (deltaMax / 2)) / deltaMax;
-
- if (r == max)
- h = deltaBlue - deltaGreen;
- else if (g == max)
- h = (1 / 3) + deltaRed - deltaBlue;
- else if (b == max)
- h = (2 / 3) + deltaGreen - deltaRed;
-
- if (h < 0)
- h += 1;
- if (h > 1)
- h -= 1;
- }
-
- return [h, s, v];
- }
-
- this.rgb2hex = function(r, g, b) {
- return this.toHex(r) + this.toHex(g) + this.toHex(b);
- };
-
- this.hexchars = "0123456789ABCDEF";
-
- this.toHex = function(n) {
- n = n || 0;
- n = parseInt(n, 10);
- if (isNaN(n))
- n = 0;
- n = Math.round(Math.min(Math.max(0, n), 255));
-
- return this.hexchars.charAt((n - n % 16) / 16) + this.hexchars.charAt(n % 16);
- };
-
- this.toDec = function(hexchar) {
- return this.hexchars.indexOf(hexchar.toUpperCase());
- };
-
- this.hex2rgb = function(str) {
- var rgb = [];
- rgb[0] = (this.toDec(str.substr(0, 1)) * 16) +
- this.toDec(str.substr(1, 1));
- rgb[1] = (this.toDec(str.substr(2, 1)) * 16) +
- this.toDec(str.substr(3, 1));
- rgb[2] = (this.toDec(str.substr(4, 1)) * 16) +
- this.toDec(str.substr(5, 1));
- return rgb;
- };
-
- this.isValidRGB = function(a) {
- if ((!a[0] && a[0] != 0) || isNaN(a[0]) || a[0] < 0 || a[0] > 255)
- return false;
- if ((!a[1] && a[1] != 0) || isNaN(a[1]) || a[1] < 0 || a[1] > 255)
- return false;
- if ((!a[2] && a[2] != 0) || isNaN(a[2]) || a[2] < 0 || a[2] > 255)
- return false;
-
- return true;
- };
- }
-
-})(window.avalon)
View
14 avalon.dialog.html
@@ -1,14 +0,0 @@
-<!--
-To change this template, choose Tools | Templates
-and open the template in the editor.
--->
-<!DOCTYPE html>
-<html>
- <head>
- <title></title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- </head>
- <body>
- <div>TODO write content</div>
- </body>
-</html>
View
184 avalon.dialog.js
@@ -1,184 +0,0 @@
-(function(avalon) {
- var defaults = {
- toggle: true,
- width: 300,
- minHeight: 150,
- height: "auto",
- minWidth: 150,
- close: avalon.noop,
- parent: "body",
- modal: false,
- autoOpen: true
- };
- var positionfixed = true;
- new function() {
- var test = document.createElement('div'),
- control = test.cloneNode(false),
- fake = false,
- root = document.body || (function() {
- fake = true;
- return document.documentElement.appendChild(document.createElement('body'));
- }());
- var oldCssText = root.style.cssText;
- root.style.cssText = 'padding:0;margin:0';
- test.style.cssText = 'position:fixed;top:42px';
- root.appendChild(test);
- root.appendChild(control);
- positionfixed = test.offsetTop !== control.offsetTop;
- root.removeChild(test);
- root.removeChild(control);
- root.style.cssText = oldCssText;
- if (fake) {
- document.documentElement.removeChild(root);
- }
- };
- if (window.Node && Node.prototype && !Node.prototype.contains) {
- Node.prototype.contains = function(arg) {
- return !!(this.compareDocumentPosition(arg) & 16);
- };
- }
- var domParser = document.createElement("div");
- domParser.innerHTML = '<div class="ui-widget-overlay ui-front">&nbsp;</div>';
- var overlay = domParser.firstChild;//全部dialog共用
- avalon.ui.dialog = function(element, id, opts, model) {
- var $element = avalon(element);
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- options.toggle = !!options.autoOpen;
- if (!options.title) {
- options.title = element.title || "&nbsp;";
- }
- if (typeof opts === "function") {
- options.close = opts;
- }
- if (typeof opts === "object") {
- for (var i in opts) {
- if (i === "$id")
- continue;
- options[i] = opts[i];
- }
- }
-
- var model;
- domParser.innerHTML = '<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front" tabindex="-1" style="position: absolute;" ' +
- ' ms-visible="toggle"' +
- ' ms-css-width="width"' +
- ' ms-css-height="height"' +
- '><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ms-draggable="drag" data-beforestart="beforestart" data-movable="false">' +
- '<span class="ui-dialog-title" ms-html="title"></span>' +
- '<button ms-ui="button" type="button" data-primary="ui-icon-closethick" class="ui-dialog-titlebar-close" data-text="false" ms-click="close">close</button></div>' +
- '</div></div>';
- var dialog = domParser.firstChild;
- if (options.nodeNodeType === 1) {
- var parent = options.parent;
- } else {
- var parent = options.parent === "parent" ? element.parentNode : document.body;
- }
- var full = false;
- $element.addClass("ui-dialog-content ui-widget-content");
- if (options.height === "auto") {
- var style = element.style;
- style.width = "auto";
- style.height = "auto";
- style.minHeight = element.clientHeight + "px";
- }
- element.removeAttribute("title");
- element.parentNode.removeChild(element);
- model = avalon.define(id, function(vm) {
- vm.toggle = options.toggle;
- vm.title = options.title;
- vm.width = options.width;
- vm.height = options.height;
- vm.close = function() {
- vm.toggle = false;
- };
- vm.$watch("toggle", function(v) {
- if (v === false) {
- avalon.Array.remove(overlayInstances, options);
- if (!overlayInstances.length) {
- if (overlay.parentNode) {
- overlay.parentNode.removeChild(overlay);
- }
- }
- } else {
- resetCenter();
- }
- });
- vm.drag = function(event, data) {
- dialog.style.top = data.top + "px";
- dialog.style.left = data.left + "px";
- };
- vm.beforestart = function(event, data) {
- data.element = dialog;
- data.$element = avalon(dialog);
-
- };
- });
- function keepFocus() {
- function checkFocus() {
- var activeElement = document.activeElement,
- isActive = dialog === activeElement || dialog.contains(activeElement);
- if (!isActive) {
- if (dialog.querySelectorAll) {
- var hasFocus = dialog.querySelectorAll("[autofocus]");
- if (!hasFocus.length) {
- hasFocus = dialog.querySelectorAll("[tabindex]");
- }
- if (!hasFocus.length) {
- hasFocus = [dialog]
- }
- hasFocus[0].focus();
- }
- }
- }
- checkFocus();
- avalon.nextTick(checkFocus);
- }
- function resetCenter() {
- if (full) {
- if (positionfixed) {
- dialog.style.position = "fixed";
- var l = (avalon(window).width() - dialog.offsetWidth) / 2;
- var t = (avalon(window).height() - dialog.offsetHeight) / 2;
- } else {
- dialog.style.setExpression('top', '( document.body.clientHeight - this.offsetHeight) / 2) + Math.max(document.documentElement.scrollTop,document.body.scrollTop) + "px"');
- dialog.style.setExpression('left', '( document.body.clientWidth - this.offsetWidth / 2) + Math.max(document.documentElement.scrollLeft,document.body.scrollLeft) + "px"');
- return;
- }
- } else {
- l = (avalon(parent).width() - dialog.offsetWidth) / 2;
- t = (avalon(parent).height() - dialog.offsetHeight) / 2;
- }
- dialog.style.left = l + "px";
- dialog.style.top = t + "px";
- keepFocus();
- if (options.modal) {
- parent.insertBefore(overlay, dialog);
- overlay.style.display = "block";
- avalon.Array.ensure(overlayInstances, options)
- }
- }
- avalon.ready(function() {
- parent.appendChild(dialog);
- dialog.appendChild(element);
- full = /body|html/i.test(dialog.offsetParent.tagName);
- if (full) {
- dialog.firstChild.setAttribute("data-containment", "window");
- }
- avalon.scan(dialog, model);
- if (options.autoOpen) {
- avalon.nextTick(resetCenter);
- }
- avalon(document.body).bind("scroll", function() {
- options.autoOpen && resetCenter();
- });
- avalon(window).bind("resize", function() {
- options.autoOpen && resetCenter();
- });
- });
- return model;
- }
- var overlayInstances = avalon.ui.dialog.overlayInstances = [];
-
-})(window.avalon);
-//http://www.slipjs.com/jz.html
View
314 avalon.draggable.js
@@ -1,314 +0,0 @@
-(function(avalon) {
- var root = avalon(document.documentElement),
- //支持触模设备
- supportTouch = "createTouch" in document || 'ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch,
- onstart = supportTouch ? "touchstart" : "mousedown",
- ondrag = supportTouch ? "touchmove" : "mousemove",
- onend = supportTouch ? "touchend" : "mouseup";
- //在元素标签上添加ms-drag="dragcallback" 就能用了,dragcallback为你在VM在定义的函数,它会在拖动时执行它
- //更在制定请在同一元素上设置data-*来制定,其中
- //data-axis="x" //值可以为x, y, xy,"", 没有设置值默认为xy, x为水平移移动,y为垂直移动, xy任意移动,""不给移
- //data-containment="parent" //值可以为window, document, parent,设置拖动的范围,没有设置就没有限制
- //data-movable="true|false", 没有设置值默认为true,是否让框架帮你移动,否则自己在dragcallback中移动
- //data-dragstart="callback", 开始拖动时执行的回调 callback为VM的某个函数
- //data-dragend="callback", 结束拖动时执行的回调
- //所有回调都有两个参数,event与data,data包含你所有data=*属性,与top, left, range, el, $el等属性
-
- scrollParent = function(node) {
- var pos = node.css("position"), parent;
- if ((window.VBArray && (/(static|relative)/).test(pos)) || (/absolute/).test(pos)) {
- parent = node[0];
- while (parent = parent.parentNode) {
- var temp = avalon(parent);
- var overflow = temp.css("overflow") + temp.css("overflow-y") + temp.css("overflow-x");
- if (/(relative|absolute|fixed)/.test(temp.css("position")) && /(auto|scroll)/.test(overflow)) {
- break;
- }
- }
- } else {
- parent = node[0];
- while (parent = parent.parentNode) {
- var temp = avalon(parent);
- var overflow = temp.css("overflow") + temp.css("overflow-y") + temp.css("overflow-x");
- if (/(auto|scroll)/.test(overflow)) {
- break;
- }
- }
- }
- parent = parent !== node[0] ? parent : null;
- return(/fixed/).test(pos) || !parent ? document : parent;
- };
- var defaults = {
- scrollSensitivity: 20,
- scrollSpeed: 20,
- movable: true,
- dragstart: avalon.noop,
- drag: avalon.noop,
- dragend: avalon.noop,
- beforestart: avalon.noop,
- scroll: true
- };
- function getXY(event, a) {
- var prop = "page" + a;
- return supportTouch ? event.targetTouches[0][prop] : event[prop];
- }
- var draggable = avalon.bindingHandlers.draggable = function(meta, scopes) {
- var element = meta.element;
- var $element = avalon(element);
- var data = avalon.mix({}, defaults);
- avalon.mix(data, $element.data());
- var axis = data.axis;
- if (axis !== "" && !/^(x|y|xy)$/.test(axis)) {
- data.axis = "xy";
- }
-
- function get(name) {
- var ret;
- for (var i = 0, scope; scope = scopes[i++]; ) {
- if (scope.hasOwnProperty(name)) {
- ret = scope[name];
- break;
- }
- }
- return ret;
- }
- data.drag = get(meta.value) || avalon.noop;
- "beforestart, dragstart, dragend".replace(avalon.rword, function(name) {
- var fn = get(data[name] || "");
- if (typeof fn === "function") {
- data[name] = fn;
- }
- });
- data.movable = data.movable !== false;
- data.element = element;
- data.$element = $element;
- function toFloat(a) {
- return parseFloat(a) || 0;
- }
-
- $element.bind(onstart, function(event) {
- data.beforestart.call(data.element, event, data);
- setDragRange(data);
- textselect(true);
- data.startX = getXY(event, "X");
- data.startY = getXY(event, "Y");
- var position = data.$element.position();
- var offset = data.$element.offset();
- if (data.containment === "window") {
- position = data.element.getBoundingClientRect();
- data.originalX = position.left;
- data.originalY = position.top;
- } else {
- data.originalX = data.originalX || position.left + data.startX - offset.left;
- data.originalY = data.originalY || position.top + data.startY - offset.top;
- }
- if (data.scroll) {
- data.scrollParent = scrollParent(data.$element);
- data.overflowOffset = avalon(data.scrollParent).offset();
- }
- // element.setCapture();有副作用
- if (window.captureEvents) {
- window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
- }
- draggable.queue.push(data);
- data.dragstart.call(data.element, event, data);
- });
- };
- draggable.queue = [];
- draggable.underway = [];
- draggable.dropscene = [];
-
- function drag(event) {
- draggable.queue.forEach(function(data) {
- event.preventDefault();
- //当前元素移动了多少距离
- data.deltaX = getXY(event, "X") - data.startX;
- data.deltaY = getXY(event, "Y") - data.startY;
- //现在的坐标
- data.offsetX = data.deltaX + data.originalX;
- data.offsetY = data.deltaY + data.originalY;
- if (data.axis.indexOf("x") !== -1) { //如果没有锁定X轴left,top,right,bottom
- var left = data.range ? Math.min(data.range[2], Math.max(data.range[0], data.offsetX)) : data.offsetX;
- if (data.movable) {
- data.element.style.left = left + "px";
- }
- data.left = left;
- }
- if (data.axis.indexOf("y") !== -1) { //如果没有锁定Y轴
- var top = data.range ? Math.min(data.range[3], Math.max(data.range[1], data.offsetY)) : data.offsetY;
- if (data.movable) {
- data.element.style.top = top + "px";
- }
- data.top = top;
- }
- setDragScroll(event, data);
- data.drag.call(data.element, event, data);
- if (window.getSelection) {
- window.getSelection().removeAllRanges();
- } else {
- document.selection.empty();
- }
- });
- }
-
- function dragEnd(event) {
- draggable.queue.forEach(function(data) {
- data.originalX = data.left;
- data.originalY = data.top;
- // data.element.releaseCapture();有副作用
- if (window.releaseEvents) {
- window.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP);
- }
- textselect(false);
- data.dragend.call(data.element, event, data);
- });
- draggable.queue.length = 0;
-
- }
- draggable.underway.push(drag);
- draggable.dropscene.push(dragEnd);
- function toFloat(a) {
- return parseFloat(a) || 0;
- }
- avalon.fn.position = function() { //取得元素相对于其offsetParent的坐标,实现拖动的关键
- var node = this[0], parentOffset = {//默认的offsetParent相对于视窗的距离
- top: 0,
- left: 0
- };
- if (!node || node.nodeType !== 1) {
- return offsetParent;
- }
- //fixed 元素是相对于window
- if (this.css("position") === "fixed") {
- var offset = node.getBoundingClientRect();
- } else {
- offset = this.offset(); //得到元素相对于视窗的距离(我们只有它的top与left)
- var offsetParent = avalon(node.offsetParent);
- //得到它的offsetParent相对于视窗的距离
- parentOffset = /html|body/i.test(offsetParent[0].nodeName) ? parentOffset : offsetParent.offset();
- parentOffset.top += toFloat(offsetParent.css("borderTopWidth"));
- parentOffset.left += toFloat(offsetParent.css("borderLeftWidth"));
- }
- return {
- top: offset.top - parentOffset.top - toFloat(this.css("marginTop")),
- left: offset.left - parentOffset.left - toFloat(this.css("marginLeft"))
- };
- };
- function setDragRange(data) {
- var range = data.containment; //处理区域鬼拽,确认可活动的范围
- var node = data.element;
- var isDoc = range === "document";
- if (range) {
- if (Array.isArray(range) && range.length === 4) { //如果传入的是坐标 [x1,y1,x2,y2] left,top,right,bottom
- data.range = range;
- } else {
- if (range === "parent") { //如果是parent参数
- range = node.parentNode;
- }
- if (isDoc || range === "window") { //如果是document|window参数
- data.range = [0, 0];
- data.range[2] = data.range[0] + avalon(isDoc ? document : window).width();
- data.range[3] = data.range[1] + avalon(isDoc ? document : window).height();
- } else { //如果是元素节点(比如从parent参数转换地来),或者是CSS表达式,或者是mass对象
- data.range = [0, 0, range.clientWidth, range.clientHeight];
- if (range !== node.offsetParent) {
- var p = avalon(range).offset();//parentNode
- var o = avalon(node.offsetParent).offset();//offsetParent
- var fixX = p.left - o.left;
- var fixY = p.top - o.top;
- data.range[0] += fixX;
- data.range[2] += fixX;
- data.range[1] += fixY;
- data.range[3] += fixY;
- }
- }
- }
- if (Array.isArray(data.range)) {
- data.range[2] = data.range[2] - node.clientWidth;
- data.range[3] = data.range[3] - node.clientHeight;
- }
-
- }
- }
- function textselect(bool) {
- //放于鼠标按下或弹起处的回调中,用于开启或禁止文本选择
- root.css("-user-select", bool ? "" : "none");
- document.unselectable = bool ? "off" : "on";
- }
- ;
- function setDragScroll(event, data, docLeft, docTop) {
- if (data.scroll) {
- if (data.scrollParent != document && data.scrollParent.tagName !== 'HTML') {
- if (data.axis.indexOf("x") !== -1) {
- if ((data.overflowOffset.left + data.scrollParent.offsetWidth) - event.pageX < data.scrollSensitivity) {
- data.scrollParent.scrollLeft = data.scrollParent.scrollLeft + data.scrollSpeed;
- } else if (event.pageX - data.overflowOffset.left < data.scrollSensitivity) {
- data.scrollParent.scrollLeft = data.scrollParent.scrollLeft - data.scrollSpeed;
- }
- }
- if (data.axis.indexOf("y") !== -1) {
- if ((data.overflowOffset.top + data.scrollParent.offsetHeight) - event.pageY < data.scrollSensitivity) {
- data.scrollParent.scrollTop = data.scrollParent.scrollTop + data.scrollSpeed;
- } else if (event.pageY - data.overflowOffset.top < data.scrollSensitivity) {
- data.scrollParent.scrollTop = data.scrollParent.scrollTop - data.scrollSpeed;
- }
- }
-
- } else {
- docLeft = docLeft || root.scrollLeft();
- docTop = docTop || root.scrollTop();
- if (data.axis.indexOf("x") !== -1) {
- if (event.pageX - docLeft < data.scrollSensitivity) {
- root.scrollLeft(docLeft - data.scrollSpeed);
- } else if (avalon(window).width() - event.pageX + docLeft < data.scrollSensitivity) {
- root.scrollLeft(docLeft + data.scrollSpeed);
- }
- }
- if (data.axis.indexOf("y") !== -1) {
- if (event.pageY - docTop < data.scrollSensitivity) {
- root.scrollTop(docTop - data.scrollSpeed);
- } else if (avalon(window).height() - event.pageY + docTop < data.scrollSensitivity) {
- root.scrollTop(docTop + data.scrollSpeed);
- }
- }
- }
- }
- }
- function getWindow(elem) {//只对window与document取值
- return elem.window && elem.document ?
- elem :
- elem.nodeType === 9 ?
- elem.defaultView || elem.parentWindow :
- false;
- }
- "scrollLeft_pageXOffset,scrollTop_pageYOffset".replace(/(\w+)_(\w+)/g, function(_, method, prop) {
- avalon.fn[method] = function(val) {
- var node = this[0] || {}, win = getWindow(node), top = method === "scrollTop";
- if (!arguments.length) {
- return win ? (prop in win) ? win[prop] : document.documentElement[method] : node[method];
- } else {
- if (win) {
- win.scrollTo(!top ? val : avalon(win).scrollLeft(), top ? val : avalon(win).scrollTop());
- } else {
- node[method] = val;
- }
- }
- };
- });
-
- //使用事件代理提高性能
- root.bind(ondrag, function(e) {
-
- for (var i = 0, fn; fn = draggable.underway[i++]; ) {
- var ret = fn(e);
- }
- return ret;
- });
- root.bind(onend, function(e) {
- for (var i = 0, fn; fn = draggable.dropscene[i++]; ) {
- var ret = fn(e);
- }
- return ret;
- });
-
-})(window.avalon);
View
2,439 avalon.js
0 additions, 2,439 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
123 avalon.pagination.js
@@ -1,123 +0,0 @@
-(function(avalon) {
- //判定是否触摸界面
- var defaults = {
- perPages: 10, //每页显示多少条目
- showPages: 10, //一共显示多页
- currentIndex: 8,
- total: 200,
- pages: [],
- nextText: "下一页&gt;",
- prevText: "&lt;上一页",
- firstPage: 0,
- lastPage: 0,
- maxPage: 0
- };
-
- var domParser = document.createElement("div");
- avalon.ui.pagination = function(element, id, opts, model) {
- var $element = avalon(element);
- var options = avalon.mix({}, defaults);
- if (typeof opts === "object") {
- for (var i in opts) {
- if (i === "$id")
- continue;
- options[i] = opts[i];
- }
- }
- avalon.mix(options, $element.data());
-
- $element.addClass("ui-widget-header ui-corner-all ui-buttonset ");
- element.style.cssText += "padding:6px 4px"
- model = avalon.define(id, function(vm) {
- avalon.mix(vm, options);
-
- function getShowPages() {
-
- var c = vm.currentIndex, p = vm.total / vm.perPages, pages = [c], s = vm.showPages, max = p,
- left = c, right = c;
- if (p <= s) {
- for (var i = 0; i < p; i++) {
- pages.push(i);
- }
- } else {
- while (true) {
- if (pages.length >= s) {
- break;
- }
- if (left >= 1) {//在日常生活是以1开始的
- pages.unshift(--left);
- }
- if (pages.length >= s) {
- break;
- }
- if (right + 1 < max) {
- pages.push(++right);
- }
-
- }
- }
- vm.firstPage = pages[0];
- vm.maxPage = max - 1;
- vm.lastPage = pages[pages.length - 1];
- return pages//[0,1,2,3,4,5,6]
- }
- vm.jumpPage = function(event) {
- event.preventDefault();
- if (this.$scope.page !== vm.currentIndex) {
- vm.currentIndex = this.$scope.page;
- vm.pages = getShowPages();
- }
- };
- vm.prevPage = function(event) {
- event.preventDefault();
- vm.currentIndex--;
- vm.pages = getShowPages();
- };
- vm.jumpFirstPage = function(event) {
- event.preventDefault();
- vm.currentIndex = 0;
- vm.pages = getShowPages();
- };
- vm.jumpLastPage = function(event) {
- event.preventDefault();
- vm.currentIndex = vm.maxPage;
- vm.pages = getShowPages();
- };
- vm.nextPage = function(event) {
- event.preventDefault();
- vm.currentIndex++;
- vm.pages = getShowPages();
- };
- vm.pages = getShowPages();
- });
- var cssText = "margin:4px 4px; padding: 2px 8px;text-decoration: none;text-align:center;";
- avalon.nextTick(function() {
- element.setAttribute("ms-each-page", "pages");
- element.innerHTML = '<a ms-href="?page={{page}}" ms-class-ui-corner-left="page == 0" ms-class-ui-corner-right="page == maxPage" ms-hover="ui-state-hover" ms-click="jumpPage" class="ui-state-default" style="' + cssText + '" ms-class-ui-state-active="currentIndex == page"' +
- ' >{{page+1}}</a>';
- avalon.scan(element, model);
- domParser.innerHTML = '<span ms-visible="firstPage" style="' + 'padding: 2px 4px;text-decoration: none;text-align:center;' + '" >…</span>' +
- '<a href="" ms-visible="firstPage" ms-hover="ui-state-hover" class="ui-state-default" style="' + cssText + '" ms-click="jumpFirstPage" >1</a>' +
- '<a href="" ms-visible="firstPage" ms-hover="ui-state-hover" class="ui-state-default ui-corner-left" style="' + cssText + '" ms-click="prevPage" ms-html="prevText"></a>' +
- '<a href="" ms-visible="lastPage != maxPage" ms-hover="ui-state-hover" class="ui-state-default ui-corner-right" style="' + cssText + '" ms-click="nextPage" ms-html="nextText"></a>' +
- '<a href="" ms-visible="lastPage != maxPage" ms-hover="ui-state-hover" class="ui-state-default" style="' + cssText + '" ms-click="jumpLastPage" >{{maxPage+1}}</a>' +
- '<span ms-visible="lastPage != maxPage" style="' + 'padding: 2px 4px;text-decoration: none;text-align:center;' + '" >…</span>';
- var a = domParser.removeChild(domParser.firstChild);
- element.insertBefore(a, element.firstChild);
- a = domParser.removeChild(domParser.firstChild);
- element.insertBefore(a, element.firstChild);
- a = domParser.removeChild(domParser.firstChild);
- element.insertBefore(a, element.firstChild);
-
- a = domParser.removeChild(domParser.lastChild);
- element.appendChild(a);
- a = domParser.removeChild(domParser.lastChild);
- element.appendChild(a);
- a = domParser.removeChild(domParser.lastChild);
- element.appendChild(a);
- avalon.scan(element, model);
- });
- return model;
- };
-
-})(this.avalon);
View
35 avalon.progressbar.js
@@ -1,35 +0,0 @@
-(function(avalon) {
- var defaults = {
- value: 0
- };
- avalon.ui.progressbar = function(element, id) {
- var $element = avalon(element),
- model, el
- var fragment = document.createDocumentFragment();
- //处理配置
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- $element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all");
- while (el = element.firstChild) {
- fragment.appendChild(el);
- }
- element.innerHTML = '<div class="ui-progressbar-value ui-widget-header ui-corner-left ui-corner-right" ms-bind-value="updateValue" style="width:' + options.value + '%;"></div>';
- while (el = element.firstChild) {
- fragment.appendChild(el);
- }
- model = avalon.define(id, function(vm) {
- vm.value = options.value;
- vm.updateValue = function(v){
- if(isFinite(v)){
- this.style.width = v + "%"
- }
- }
- });
- avalon.nextTick(function() {
- element.appendChild(fragment);
- avalon.scan(element.parentNode, model);
- });
- return model;
- }
-})(this.avalon);
-//6月2日 3群 上海-Jason
View
379 avalon.router.js
@@ -1,379 +0,0 @@
-/*********************************************************************
- * History *
- **********************************************************************/
-//暴露如下接口:avalon.history.start, avalon.history.stop, avalon.history.interval
-//avalon.Router.extend, avalon.Router.navigate
-if (![].reduce) {
- Array.prototype.reduce = function(fn, lastResult, scope) {
- if (this.length == 0)
- return lastResult;
- var i = lastResult !== undefined ? 0 : 1;
- var result = lastResult !== undefined ? lastResult : this[0];
- for (var n = this.length; i < n; i++)
- result = fn.call(scope, result, this[i], i, this);
- return result;
- }
-}
-avalon.history = new function() {
- var oldIE = !"1" [0];
- var started = false;
- var self = this;
- var firstCheck;
- var iframeWin, iframe, history_hash, timeoutID;
- var last_hash = "#!" + getFragment();
- var supportPushState = /[native code]/.test(history.pushState);
- var html = '<!doctype html><html><body>@</body></html>';
- if (this.domain) {
- html = html.replace("<body>", "<script>document.domain =" + this.domain + "</script><body>");
- }
- function createIframe() {
- if (!iframe && oldIE) {
- iframe = document.createElement("iframe");
- iframe.tabIndex = -1;
- iframe.style.display = "none";
- iframe.src = "javascript:false";
- (document.body || document.documentElement).appendChild(iframe);
- var doc = iframe.contentDocument || iframe.contentWindow.document;
- doc.write(html.replace("@", last_hash));
- doc.close();
- timeoutID = setInterval(poll, self.interval);
- }
- }
- // IE6直接用location.hash取hash,可能会取少一部分内容
- // 比如 http://www.cnblogs.com/rubylouvre#stream/xxxxx?lang=zh_c
- // ie6 => location.hash = #stream/xxxxx
- // 其他浏览器 => location.hash = #stream/xxxxx?lang=zh_c
- // firefox 会自作多情对hash进行decodeURIComponent
- // 又比如 http://www.cnblogs.com/rubylouvre/#!/home/q={%22thedate%22:%2220121010~20121010%22}
- // firefox 15 => #!/home/q={"thedate":"20121010~20121010"}
- // 其他浏览器 => #!/home/q={%22thedate%22:%2220121010~20121010%22}
- function getHash(url, shim) {//用于取得当前窗口或iframe窗口的hash值
- url = url || document.URL;
- return url.slice(url.indexOf("#") + (~~shim));
- }
- function getHistory() {
- return getHash(iframeWin.location);
- }
- function setHistory(hash, history_hash) {
- if (hash !== history_hash) {//只有当新hash不等于iframe中的hash才重写
- //用于产生历史
- try {
- var iframeDoc = getDoc();
- iframeDoc.open();
- iframeDoc.write(html.replace("@", hash));
- iframeDoc.close();
- } catch (e) {
- clearInterval(timeoutID);
- }
- }
- }
- function getFragment() {
- var href = location.href;
- var index = href.indexOf(location.pathname.slice(1));
- return href.slice(index);
- }
- function getDoc() {
- return iframe.contentDocument || iframe.contentWindow.document;
- }
-
- function poll(e) {
- if (iframe) {
- var iframeDoc = getDoc(),
- hash = getHash();//取得主窗口中的hash
- history_hash = iframeDoc.body.innerText;//取得现在iframe中的hash
- if (hash !== last_hash) {//如果是主窗口的hash发生变化
- if (hash.indexOf("#!") !== 0) {
- hash = "#!" + getFragment();
- location.hash = hash;
- }
- if (!firstCheck) {
- firstCheck = true;
- } else {
- var path = hash.split("#")[2];
- avalon.Router.navigate(typeof path === "string" ? path : new Date-0);
- setHistory(last_hash = hash, history_hash);
- }
- } else if (history_hash !== last_hash) {//如果按下回退键,
- // avalon.log("用户点了回退键,导致iframe中的hash发生变化" + history_hash);
- location.href = location.href.replace(/#.*/, '') + history_hash;
- }
- }
- }
- avalon.mix(this, {
- interval: 35,
- start: function(html5mode) {
- if (started)
- avalon.error("start已经触发过了");
- started = true;
- createIframe();
- this.html5mode = !!html5mode;
- if (window.opera || window.VBArray || !supportPushState) {
- this.html5mode = false;
- }
- //如果我们想在改动URL时不刷新地址
- // http://foo.com/bar?baz=23#bar
- // http://foo.com/#!/bar?bar=23#bar
-
- this.checkUrl = function() {
- if (!firstCheck) {
- return firstCheck = true
- }
- var path = getHash(getFragment(), true);
- avalon.Router.navigate(path)
- }
- if (this.html5mode) { //如果支持pushState
- //http://caniuse.com/#search=pushstate
- window.addEventListener("popstate", this.checkUrl);
- } else if (window.opera || document.documentMode >= 8) {
- //http://caniuse.com/#search=pushstate
- this.checkUrl = avalon.bind(window, "hashchange", this.checkUrl);
- }
- },
- stop: function() {
- //停止事件监听或interval
- avalon.unbind(window, "popstate", this.checkUrl).unbind(window, "hashchange", this.checkUrl);
- clearInterval(timeoutID);
- started = false;
- }
- });
-}
-/*********************************************************************
- * Router *
- **********************************************************************/
-new function() {
- //表的结构:method+segments.length 普通字段
- function _tokenize(pathStr) {
- var stack = [''];
- for (var i = 0; i < pathStr.length; i++) {
- var chr = pathStr.charAt(i);
- if (chr === '/') {//用于让后面的字符串相加
- stack.push('');
- continue;
- } else if (chr === '(') {
- stack.push('(');
- stack.push('');
- } else if (chr === ')') {
- stack.push(')');
- stack.push('');
- } else {
- stack[stack.length - 1] += chr;
- }
- }
- return stack.filter(function(str) {
- return str.length !== 0;
- });
- }
- ;
- //将( ) 转换为数组的两端,最后构成一个多维数组返回
- function _parse(tokens) {
- var smallAst = [];
- var token;
- while ((token = tokens.shift()) !== void 0) {
- if (token.length <= 0) {
- continue;
- }
- switch (token) {
- case '(':
- smallAst.push(_parse(tokens));
- break;
- case ')':
- return smallAst;
- default:
- smallAst.push(token);
- }
- }
- return smallAst;
- }
- var combine = function(list, func) {
- var first = list.shift();
- var second = list.shift();
- if (second === undefined) {
- return first;
- }
- var combination = first.map(function(val1) {
- return second.map(function(val2) {
- return func(val1, val2);
- });
- }).reduce(function(val1, val2) {
- return val1.concat(val2);
- });
- if (list.length === 0) {
- return combination;
- } else {
- return combine([combination].concat(list), func);
- }
- };
- function parse(rule) {
- var tokens = _tokenize(rule);
- var ast = _parse(tokens);
- return ast;
- }
-
- function Router() {
- this.routingTable = {};
- }
- function parseQuery(path) {
- var array = path.split("#"), query = {}, tail = array[1];
- if (tail) {
- var index = tail.indexOf("?");
- if (index > 0) {
- var seg = tail.slice(index + 1).split('&'),
- len = seg.length, i = 0, s;
- for (; i < len; i++) {
- if (!seg[i]) {
- continue;
- }
- s = seg[i].split('=');
- query[decodeURIComponent(s[0])] = decodeURIComponent(s[1]);
- }
- }
- }
- return {
- pathname: array[0],
- query: query
- };
- }
-
- Router.prototype = {
- _set: function(table, query, value) {
- var nextKey = query.shift();//构建一个前缀树,用于高速匹对给定的URL
- if (nextKey.length <= 0) {
- avalon.error('构建失败');
- }
- if (nextKey.charAt && nextKey.charAt(0) === ':') {//如果碰到参数
- var n = nextKey.substring(1);
- if (table.hasOwnProperty('^n') && table['^n'] !== n) {
- return false;
- }
- table['^n'] = n;
- nextKey = '^v';
- }
- if (query.length === 0) {
- table[nextKey] = value;
- return true;
- } else {
- var nextTable = table.hasOwnProperty(nextKey) ?
- table[nextKey] : table[nextKey] = {};
- return this._set(nextTable, query, value);
- }
- },
- add: function(method, path, value) {
- var ast = parse(path); //转换为抽象语法树
-
- var patterns = this._expandRules(ast);//进行全排列,应对可选的fragment
-
- if (patterns.length === 0) {
- var query = [method, 0];
- this._set(this.routingTable, query, value);
- } else {
- var self = this
- patterns.every(function(pattern) {
- var length = pattern.length,
- query = [method, length].concat(pattern);
- return self._set(self.routingTable, query, value);
- });
- }
- return value;
- },
- routeWithQuery: function(method, path) {
- var parsedUrl = parseQuery(path),
- ret = this.route(method, parsedUrl.pathname);
- if (ret) {
- ret.query = parsedUrl.query;
- return ret;
- }
- },
- route: function(method, path) {//将当前URL与
- path = path.trim();
- var splitted = path.split('/'),
- query = Array(splitted.length),
- index = 0,
- params = {},
- table = [],
- args = [],
- val, key, j;
- for (var i = 0; i < splitted.length; ++i) {
- val = splitted[i];
- if (val.length !== 0) {
- query[index] = val;
- index++;
- }
- }
- query.length = index;
- table = this.routingTable[method];
- if (table === void 0)
- return;
- table = table[query.length];
- if (table === void 0)
- return;
- for (j = 0; j < query.length; ++j) {
- key = query[j];
- if (table.hasOwnProperty(key)) {
- table = table[key];
- } else if (table.hasOwnProperty('^v')) {
- params[table['^n']] = key;
- args.push(key)
- table = table['^v'];
- } else {
- return;
- }
- }
- return {
- query: {},
- args: args,
- params: params,
- value: table
- };
- },
- _expandRules: function(ast) {
- if (Array.isArray(ast) && ast.length === 0) {
- return [];
- }
- var self = this;
- var result = combine(ast.map(function(val) {
- if (typeof val === 'string') {
- return [[val]];
- } else if (Array.isArray(val)) {
- return self._expandRules(val).concat([[]]);
- } else {
- throw new Error('这里的值只能是字符串或数组 {{' + val + '}}');
- }
- }), function(a, b) {
- return a.concat(b);
- });
- return result;
- }
- };
- var callbacks = {}, errback, router = new Router();
- avalon.Router = {
- extend: function(obj) {//定义所有路由规则
- if (typeof obj.routes === "object") {
- for (var i in obj.routes) {
- if (i === "*error") {
- errback = obj.routes[i]
- } else {
- router.add("GET", i, obj.routes[i]);
- }
- }
- }
- for (var i in obj) {
- if (typeof obj[i] === "function") {
- callbacks[i] = obj[i];
- }
- }
- },
- navigate: function(url) {//传入一个URL,触发预定义的回调
- var match = router.routeWithQuery("GET", url);
- if (match) {
- var key = match.value;
- if (typeof callbacks[key] === "function") {
- return callbacks[key].apply(match, match.args);
- }
- }
- if (typeof callbacks[errback] === "function") {
- callbacks[errback](url);
- }
- }
- };
-
-}
View
23 avalon.select.css
@@ -1,23 +0,0 @@
-.ui-multiselect { padding:2px 0 2px 4px; text-align:left }
-.ui-multiselect span.ui-icon { float:right }
-.ui-multiselect-single .ui-multiselect-checkboxes input { position:absolute !important; top: auto !important; left:-9999px; }
-.ui-multiselect-single .ui-multiselect-checkboxes label { padding:5px !important }
-
-.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 4px }
-.ui-multiselect-header ul { font-size:0.9em }
-.ui-multiselect-header ul li { float:left; padding:0 10px 0 0 }
-.ui-multiselect-header a { text-decoration:none }
-.ui-multiselect-header a:hover { text-decoration:underline }
-.ui-multiselect-header span.ui-icon { float:left }
-.ui-multiselect-header li.ui-multiselect-close { float:right; text-align:right; padding-right:0 }
-
-.ui-multiselect-menu { display:none; padding:3px; position:absolute; z-index:10000; text-align: left }
-.ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; overflow-y:scroll }
-.ui-multiselect-checkboxes label { cursor:default; display:block; border:1px solid transparent; padding:3px 1px }
-.ui-multiselect-checkboxes label input { position:relative; top:1px }
-.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; padding-right:3px }
-.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label { text-align:center; font-weight:bold; border-bottom:1px solid }
-.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label a { display:block; padding:3px; margin:1px 0; text-decoration:none }
-
-/* remove label borders in IE6 because IE6 does not support transparency */
-* html .ui-multiselect-checkboxes label { border:none }
View
173 avalon.select.js
@@ -1,173 +0,0 @@
-(function(avalon) {
- //判定是否触摸界面
- var defaults = {
- minWidth: 225,
- height: 175,
- toggle: false,
- caption: "请选择",
- selectedIndex: 0,
- checkAllText: "全选",
- unCheckAllText: "全不选",
- onChange: avalon.noop,
- onOpen: avalon.noop,
- onClose: avalon.noop
- };
- var domParser = document.createElement("div");
-
- avalon.ui["select"] = function(element, id, opts, model) {
- var $element = avalon(element);
- var options = avalon.mix({}, defaults);
- if (typeof opts === "object") {
- for (var i in opts) {
- if (i === "$id")
- continue;
- options[i] = opts[i];
- }
- }
- avalon.mix(options, $element.data());
- domParser.innerHTML = '<button type="button" ms-hover="ui-state-hover" ms-active="ui-state-focus" ms-click="toggleMenu" class="ui-multiselect ui-widget ui-state-default ui-corner-all" aria-haspopup="true" >' +
- '<span class="ui-icon ui-icon-triangle-2-n-s"></span><span>{{caption}}</span></button>';
- var button = domParser.removeChild(domParser.firstChild);
- button.style.minWidth = options.minWidth + "px";
- button.style.width = Math.max(options.minWidth, element.offsetWidth) + "px";
- button.title = element.title;
- $element.addClass("ui-helper-hidden-accessible");
-
- domParser.innerHTML = '<div class="ui-multiselect-menu ui-widget ui-widget-content ui-corner-all"'
- + ' ms-visible="toggle" tabindex="-1">'
- + '<div class="ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix">'
- + '<ul class="ui-helper-reset">'
- + '<span ms-if="!multiple">' + options.caption + '</span>'
- + '<li ms-if="multiple"><a class="ui-multiselect-all" href="return false" ms-click="checkAll"><span class="ui-icon ui-icon-check"></span><span>{{checkAllText}}</span></a></li>'
- + '<li ms-if="multiple"><a class="ui-multiselect-none" href="return false" ms-click="unCheckAll"><span class="ui-icon ui-icon-closethick"></span><span>{{unCheckAllText}}</span></a></li>'
- + '<li class="ui-multiselect-close"><a href="#" class="ui-multiselect-close" ms-click="closeMenu"><span class="ui-icon ui-icon-circle-close"></span></a></li>'
- + '</ul></div>'
- + '<ul class="ui-multiselect-checkboxes ui-helper-reset" ms-css-height="height" ms-each-el="list" >'
- + '<li ms-class-ui-multiselect-optgroup-label="!el.isOption" >'
- + '<a href="#" ms-if="!el.isOption" >{{el.text}}</a>'
- + '<label for="rubylouvre" ms-if="el.isOption" ms-hover="ui-state-hover" ms-class-ui-state-disabled="el.disabled" ms-click="changeState" class="ui-corner-all">'
- + '<input ms-visible="multiple" ms-disabled="el.disabled" ms-checked="el.selected" type="checkbox"><span>{{el.text}}</span></label></li>'
- + '</ul></div>';
- var list = [], index = 0, els = [];
- function getOptions(i, el) {
- if (el.tagName === "OPTION") {
- list.push({
- isOption: true,
- text: el.text,
- index: index++,
- selected: !el.disabled && el.selected,
- disabled: el.disabled
- });
- els.push(el);
- } else if (el.tagName === "OPTGROUP") {
- list.push({
- isOption: false,
- text: el.label,
- index: 0,
- selected: false,
- disabled: true
- });
- els.push(el);
- avalon.each(el.childNodes, getOptions);
- }
- }
-
- avalon.each(element.childNodes, getOptions);
-
- var menu = domParser.removeChild(domParser.firstChild);
- menu.style.width = button.style.width;
- var curCaption = options.caption;
- var canClose = false;
-
- avalon.bind(button, "mouseenter", function(e) {
- canClose = false;
- });
- avalon.bind(menu, "mouseenter", function(e) {
- canClose = false;
- });
- avalon.bind(menu, "mouseleave", function(e) {
- canClose = true;
- });
- avalon.bind(document, "click", function(e) {
- if (canClose) {
- model.toggle = false;
- }
- });
- model = avalon.define(id, function(vm) {
- avalon.mix(vm, options);
- vm.list = list;
- vm.multiple = element.multiple;
- function getCaption() {
- if (vm.multiple) {
- var l = vm.list.filter(function(el) {
- return el.isOption && el.selected && !el.disabled;
- }).length;
- return l ? l + " selected" : curCaption;
- } else {
- return element[element.selectedIndex].text;
- }
- }
- vm.caption = getCaption();
- vm.toggleMenu = function() {
- vm.toggle = !vm.toggle;
- };
- vm.$watch("toggle", function(v) {
- if (v) {
- var offset = avalon(button).offset();
- menu.style.top = offset.top + button.offsetHeight + "px";
- menu.style.left = offset.left + "px";
- options.onOpen.call(element);
- } else {
- options.onClose.call(element);
- }
- });
- vm.closeMenu = function(e) {
- e.preventDefault();
- vm.toggle = false;
- };
- vm.checkAll = function(e, val) {
- e.preventDefault();
- val = !val;
- vm.list.forEach(function(el) {
- if (el.isOption && !el.disabled) {
- el.selected = val;
- }
- });
- vm.caption = getCaption();
- };
- vm.unCheckAll = function(e) {
- vm.checkAll(e, true);
- };
-
- vm.changeState = function(e) {
- var obj = this.$scope.el;
- if (!obj.disabled) {//重要技巧,通过e.target == this排除冒泡上来的事件
- var index = obj.index;
- var option = els[index];
- if (vm.multiple) {
- var a = obj.selected;
- option.selected = obj.selected = !a
- } else {
- element.selectedIndex = vm.selectedIndex = index;
- option.selected = true;
- setTimeout(function() {
- vm.toggle = false;
- }, 250);
- }
- options.onChange.call(element);
- vm.caption = getCaption();
- }
- };
- });
- avalon.ready(function() {
- element.parentNode.insertBefore(button, element.nextSibling);
- avalon.scan(button, model);
- document.body.appendChild(menu);
- avalon.scan(menu, model);
- });
-
- return model;
- };
-
-})(window.avalon);
-//http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/#single
View
154 avalon.slider.js
@@ -1,154 +0,0 @@
-(function(avalon) {
- //判定是否触摸界面
- var defaults = {
- distance: 0,
- max: 100,
- min: 0,
- orientation: "horizontal",
- range: false,
- step: 1,
- value: 0,
- values: null
- }
- var domParser = document.createElement("div");
-
- avalon.ui["slider"] = function(element, id, opt, model) {
- var $element = avalon(element);
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- var isHorizontal = options.orientation === "horizontal";
- //将整个slider划分为N等分, 比如100, 227
- var valueMin = options.min;
- var valueMax = options.max;
- var oRange = options.range; //true min max
- var values = options.values;
- var twohandlebars = oRange === true;
- //处理
- var value = options.value; //第几等份
- if (oRange === "min" && values) {
- var value = values[0];
- } else if (oRange === "max" && values) {
- value = values[1];
- }
- if (twohandlebars) {
- if (Array.isArray(values)) {
- values = values.length === 1 ? [values[0], values[0]] : values.concat();
- } else {
- values = [valueMin, valueMax];
- }
- }
-
-
- var handleHTML = '<a class="ui-slider-handle ui-state-default ui-corner-all"' +
- ' ms-css-' + (isHorizontal ? 'left' : 'bottom') + '="{{percent}}%"' +
- ' data-axis=' + (isHorizontal ? 'x' : 'y') +
- ' data-containment="parent"' +
- ' ms-draggable="drag"' +
- ' data-movable="false"' +
- ' data-dragstart="dragstart"' +
- ' data-dragend="dragend"' +
- ' ms-hover="ui-state-hover" href="javascript:void(0)" ></a>';
- var rangeHTML = ' <div class="ui-slider-range ui-widget-header ui-corner-all"' +
- ' ms-class-ui-slider-range-max="range === \'max\'" ' +
- ' ms-class-ui-slider-range-min="range === \'min\'" ' +
- (twohandlebars ? ' ms-css-' + (isHorizontal ? 'left' : 'bottom') + '="{{ percent0 }}%"' : "") +
- ' ms-css-' + (isHorizontal ? 'width' : 'height') + '="{{ range === \'max\' ? 100 - percent : percent}}%"></div>';
- var sliderHTML = '<div class="ui-slider ui-slider-' + options.orientation +
- ' ui-widget ui-widget-content ui-corner-all" ' +
- ' ms-class-ui-state-disabled="disabled" >' +
- (oRange ? rangeHTML : "") + (twohandlebars ? handleHTML.replace("percent", "percent0") +
- handleHTML.replace("percent", "percent1") : handleHTML) +
- '</div>';
- domParser.innerHTML = sliderHTML;
- var slider = domParser.removeChild(domParser.firstChild);
- var a = slider.getElementsByTagName("a"), handlers = [];
- for (var i = 0, el; el = a[i++]; ) {
- handlers.push(el);
- }
- element.parentNode.insertBefore(slider, element.nextSibling);
- $element.addClass("ui-helper-hidden-accessible");
- var Index = 0, pixelTotal;
- function value2Percent(val) {
- if (val < valueMin) {
- val = valueMin;
- }
- if (val > valueMax) {
- val = valueMax;
- }
- return parseFloat((val / valueMax * 100).toFixed(5));
- }
- function percent2Value(percent) {//0~1
- var val = valueMax * percent;
- var step = (options.step > 0) ? options.step : 1;
-
- var valModStep = val % step;
- var n = val / step;
- val = valModStep * 2 >= step ? step * Math.ceil(n) : step * Math.floor(n);
- // console.log(parseFloat(val.toFixed(3))+" step "+n)
- return parseFloat(val.toFixed(3));
- }
- model = avalon.define(id, function(vm) {
- vm.disabled = element.disabled;
- vm.percent = twohandlebars ? value2Percent(values[1] - values[0]) : value2Percent(value);
- vm.percent0 = twohandlebars ? value2Percent(values[0]) : 0;
- vm.percent1 = twohandlebars ? value2Percent(values[1]) : 0;
- vm.value = twohandlebars ? values.join() : value;
- vm.range = oRange;
- vm.values = values;
- vm.dragstart = function(event, data) {
- Index = handlers.indexOf(data.element);
- data.$element.addClass("ui-state-active");
- data.range[2] += this.clientWidth;
- data.range[3] += this.clientHeight;
- pixelTotal = isHorizontal ? slider.offsetWidth : slider.offsetHeight;
- };
- vm.dragend = function(event, data) {
- data.$element.removeClass("ui-state-active");
- };
- vm.drag = function(event, data) {
- var prop = isHorizontal ? "left" : "top";
- var pixelMouse = data[prop];
- //如果是垂直时,往上拖,值就越大
- var percent = (pixelMouse / pixelTotal); //求出当前handler在slider的位置
- if (!isHorizontal) {
- percent = Math.abs(1 - percent);
- }
- if (percent > 0.99) {
- percent = 1;
- }
- if (percent < 0.01) {
- percent = 0;
- }
- var val = percent2Value(percent);
- if (twohandlebars) { //水平时,小的0在左边,大的1在右边,垂直时,大的0在下边,小的1在上边
- if (Index === 0) {
- var check = vm.values[1];
- if (val > check) {
- val = check;
- }
- } else {
- check = vm.values[0];
- if (val < check) {
- val = check;
- }
- }
- vm.values[Index] = val;
- vm["percent" + Index] = value2Percent(val);
- vm.value = vm.values.join();
- vm.percent = value2Percent(vm.values[1] - vm.values[0]);
- } else {
- vm.value = val;
- vm.percent = value2Percent(val);
- }
- };
-
- });
-
- avalon.scan(slider, model);
- return model;
- };
-
-})(window.avalon);
-//http://xinranliu.me/?p=520
-//http://www.w3cplus.com/css3/using-flexbox.html
-//http://www.w3cplus.com/css3/css-generated-content-counters.html
View
62 avalon.spinner.js
@@ -1,62 +0,0 @@
-(function(avalon) {
- var defaults = {
- value: 0,
- min: 1 << 31,
- max: Infinity,
- step: 1
- };
- avalon.ui.spinner = function(element, id) {
- var $element = avalon(element),
- model, el;
- var fragment = document.createDocumentFragment();
- //处理配置
- var options = avalon.mix({}, defaults);
- avalon.mix(options, $element.data());
- var span = document.createElement("span");
- span.className = "ui-spinner ui-widget ui-widget-content ui-corner-all";
- span.innerHTML = '<a class="ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" >' +
- '<span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-n">&#9650;</span></span></a>' +
- '<a class="ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" >' +
- '<span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-s">&#9660;</span></span></a>';
- $element.addClass("ui-spinner-input");
-
- element.autocomplete = "off";
- element.parentNode.insertBefore(span, element.nextSibling);
- fragment.appendChild(element);
- var buttons = [];
- while (el = span.firstChild) {
- if (el.tagName === "A") {
- buttons.push(el);
- }
- fragment.appendChild(el);
- }
- element.setAttribute("ms-value", "value");
- element = span;//偷天换日
- $element = avalon(span);
- model = avalon.define(id, function(vm) {
- vm.min = options.min;
- avalon.mix(vm, options );
- vm.addNumber = function(e) {
- e.preventDefault();
- vm.value += vm.step;
- if (vm.value > vm.max) {
- vm.value = vm.max;
- }
- };
- vm.reduceNumber = function(e) {
- e.preventDefault();
- vm.value -= vm.step;
- if (vm.value < vm.min) {
- vm.value = vm.min;
- }
- };
- });
- avalon.nextTick(function() {
- buttons[0].setAttribute("ms-click", "addNumber");
- buttons[1].setAttribute("ms-click", "reduceNumber");
- element.appendChild(fragment);
- avalon.scan(element, model);
- });
- return model;
- };
-})(this.avalon);
View
92 avalon.switch.js
@@ -1,92 +0,0 @@
-(function(avalon) {
- //判定是否触摸界面
- var defaults = {
- disabled: false,
- leftText: "ON",
- rightText: "OFF"
- };
- var domParser = document.createElement("div");
-
- domParser.innerHTML = "#<style>.white-gradient{background-color: #ffffff;" +
- "background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);" +
- "background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);" +
- "background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6);" +
- "background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);" +
- "background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);" +
- "background-repeat: repeat-x;}</style>";
- var style = domParser.removeChild(domParser.lastChild);