diff --git a/build/css/ox.ui.css b/build/css/ox.ui.css index 1912e56c..a2662d22 100644 --- a/build/css/ox.ui.css +++ b/build/css/ox.ui.css @@ -1240,6 +1240,63 @@ Panels position: absolute; } +.OxSplitPanel2 { + display: box; + display: -moz-box; + display: -webkit-box; + overflow: hidden; + box-flex: 0; + -mox-box-flex: 0; + -webkit-box-flex: 0; +} +.OxSplitPanel2.OxHorizontal { + box-orient: horizontal; + -moz-box-orient: horizontal; + -webkit-box-orient: horizontal; +} +.OxSplitPanel2.OxVertical { + box-orient: vertical; + -moz-box-orient: vertical; + -webkit-box-orient: vertical; +} +.OxSplitPanel2 > * { + box-flex: 0; + -mox-box-flex: 0; + -webkit-box-flex: 0; +} +.OxSplitPanel2 > .OxSeparator { + display: -webkit-box; + position: relative; + z-index: 2; +} +.OxSplitPanel2 > .OxSeparator > * { + -webkit-box-flex: 0; +} +.OxSplitPanel2 > .OxSeparator > .OxLine { + background-color: black; +} +.OxSplitPanel2.OxHorizontal > .OxSeparator { + width: 5px; + margin: 0 -2px 0 -2px; + cursor: ew-resize; +} +.OxSplitPanel2.OxHorizontal > .OxSeparator > .OxLine { + width: 1px; +} +.OxSplitPanel2.OxHorizontal > .OxSeparator > .OxSpace { + width: 2px; +} +.OxSplitPanel2.OxVertical > .OxSeparator { + height: 5px; + margin: -2px 0 -2px 0; + cursor: ns-resize; +} +.OxSplitPanel2.OxVertical > .OxSeparator > .OxLine { + height: 1px; +} +.OxSplitPanel2.OxVertical > .OxSeparator > .OxSpace { + height: 2px; +} /* ================================================================================ Requests diff --git a/build/js/ox.js b/build/js/ox.js index 0fcc9218..539cb8e0 100644 --- a/build/js/ox.js +++ b/build/js/ox.js @@ -1,8 +1,29 @@ // todo: check http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ -var Ox = { - version: '0.1.2' -}; +/* +(function() { + var methods = { + 'array': ['pop', 'push', 'shift', 'unshift'], + 'string': [ + 'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', + 'match', 'replace', 'search', 'slice', 'split', + 'substr', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', + 'toString', 'toUpperCase', 'trim', 'trimLeft, 'trimRight', + 'valueOf' + ] + }, + global = this; + return function Ox(val) { + var ret, + type = Ox.typeof(val); + if (type == 'array') { + + } + } +})(); +*/ + +Ox = {}; /* ================================================================================ @@ -74,6 +95,7 @@ Ox.TYPES = [ 'Arguments', 'Array', 'Boolean', 'Date', 'Element', 'Function', 'Infinity', 'NaN', 'Null', 'Number', 'Object', 'RegExp', 'String', 'Undefined' ]; +Ox.VERSION = '0.1.2'; Ox.WEEKDAYS = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]; @@ -99,7 +121,7 @@ Ox.getset = function(obj, args, callback, context) { Ox.getset(obj, [key, val], callback, context) Ox.getset(obj, [{key: val, ...}], callback, context) sets obj.key to val, calls callback(key, val) - for any changed value, + for each changed value, returns context (for chaining) @@ -2310,7 +2332,7 @@ Ox.endsWith = function(str, sub) { >>> Ox.endsWith("foobar", "bar") true */ - return str.substr(-sub.length) === sub; + return str.toString().substr(-sub.length) === sub; }; Ox.highlight = function(txt, str) { @@ -2371,7 +2393,7 @@ Ox.reverse = function(str) { Ox.reverse("foo") oof */ - return str.split('').reverse().join(''); + return str.toString().split('').reverse().join(''); }; Ox.startsWith = function(str, sub) { @@ -2379,7 +2401,7 @@ Ox.startsWith = function(str, sub) { >>> Ox.startsWith("foobar", "foo") true */ - return str.substr(0, sub.length) === sub; + return str.toString().substr(0, sub.length) === sub; }; Ox.stripTags = function(str) { diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index bb5c7fd7..5cadb0b5 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -772,20 +772,42 @@ requires }; Ox.UI = (function() { + /* + $(function() { + Ox.extend(Ox.UI, { + $body: $('body'), + $document: $(document), + $window: $(window) + }); + }); + */ return { - $body: $('body'), - $document: $(document), - $window: $(window), - path: function() { - return oxui.path; + getDimensions: function(orientation) { + return orientation == 'horizontal' ? + ['width', 'height'] : ['height', 'width']; }, + getEdges: function(orientation) { + return orientation == 'horizontal' ? + ['left', 'right', 'top', 'bottom'] : + ['top', 'bottom', 'left', 'right']; + }, + DIMENSIONS: { + horizontal: ['width', 'height'], + vertical: ['height', 'width'] + }, + EDGES: { + horizontal: [['left', 'right'], ['top', 'bottom']], + vertical: [['top', 'bottom'], ['left', 'right']] + }, + PATH: $('script[src*="ox.ui.js"]') + .attr('src').replace('js/ox.ui.js', ''), theme: function() { }, themePath: function() { } - } + }; }()); /*** @@ -881,7 +903,7 @@ requires element: self.options }; } - that.ox = Ox.version; + that.ox = Ox.VERSION; that.id = Ox.uid(); that.$element = $('<' + (self.options.element || 'div') + '/>', { data: { @@ -11142,6 +11164,213 @@ requires return that; }; + Ox.SplitPanel2 = function(options, self) { + + var self = self || {}, + that = new Ox.Element('div', self) + .defaults({ + elements: [], + orientation: 'horizontal' + }) + .options(options) + .addClass( + 'OxSplitPanel2 Ox' + Ox.toTitleCase(self.options.orientation) + ); + + Ox.extend(self, { + $separators: [], + clientXY: self.options.orientation == 'horizontal' ? 'clientX' : 'clientY', + dimensions: Ox.UI.DIMENSIONS[self.options.orientation], + edges: Ox.UI.EDGES[self.options.orientation] + }); + + self.options.elements.forEach(function(element, i) { + self.options.elements[i] = Ox.extend({ + collapsible: false, + collapsed: false, + resizable: false, + resize: [], + size: 'auto' + }, element); + }); + + self.autoPercent = (100 - self.options.elements.reduce(function(val, element) { + return val + (Ox.endsWith(element.size, '%') ? parseFloat(element.size) : 0); + }, 0)) / self.options.elements.filter(function(element) { + return element.size == 'auto'; + }).length + '%'; + + self.options.elements.forEach(function(element, i) { + var flex, index = i == 0 ? 0 : 1; + if (Ox.isNumber(element.size)) { + element.element.css(self.dimensions[0], element.size + 'px'); + } else { + flex = ( + element.size == 'auto' ? self.autoPercent : element.size + ).replace('%', ''); + element.element.css({ + boxFlex: flex, + MozBoxFlex: flex, + WebkitBoxFlex: flex + }); + } + element.element.appendTo(that); + if (element.collapsible || element.resizable) { + self.$separators.push( + Ox.Element() + .addClass('OxSeparator') + .bindEvent({ + anyclick: function() { + that.toggle(i); + }, + dragstart: function(event, e) { + dragstart(i, e); + }, + drag: function(event, e) { + drag(i, e); + }, + dragend: function(event, e) { + dragend(i, e); + }, + }) + .append($('